Hi here is my code, doesn't seem to work. I am not sure what I'm missing I see the reference is generated but at the end its not inserted:
string jobRef = new Random().Next(1000, 9999).ToString();
if (ModelState.IsValid)
{
var model = new Job
{
Name = job.Name,
JobNo = job.JobNo,
Description = job.Description,
Location = job.Location,
CustomerId = job.CustomerId,
JobCategoryId = job.JobCategoryId,
CreatedDate = DateTime.Now,
Reference = DateTime.Now.ToString("yyyyMM") + "-" + jobRef,
};
_context.Add(job);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Inprogress));
}
Reference its a string on my model
public string Reference { get; set; }
Please kindly assist what am I doing wrong
What I have tried:
Please check above code, the reference is generated successfully but not inserted