public ActionResult AddWorkTimeLog(TicketWorkLogViewModel model) { var userid = User.Identity.GetUserId(); if (ModelState.IsValid) { db.TicketWorkLogs.Add(new TicketWorkLog { TwL_ASSID = userid, TwL_TIHID = model.TwL_TIHID, TwL_StartDate = model.TwL_StartDate, TwL_EndDate = model.TwL_EndDate, TwL_SpendMinutes = (model.TwL_SpendHours * 60) + model.TwL_SpendMinutes, TwL_Description = model.TwL_Description == null ? "" : model.TwL_Description, TwL_PublicDescription = model.TwL_PublicDescription }); db.SaveChanges(); TempData["Success"] = "Pomyślnie dodano wpis w dzienniku pracy"; return(RedirectToAction("Details", new { id = model.TwL_TIHID })); } TempData["Error"] = "Przy próbie dodania dziennika pracy wystąpły błędy:<p>" + string.Join("<p>", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage + "</p>")); return(RedirectToAction("Details", new { id = model.TwL_TIHID })); }
public ActionResult AddWorkTimeLog(int?id) { var _twlModel = new TicketWorkLogViewModel { TwL_TIHID = id, TwL_StartDate = DateTime.Now, TwL_EndDate = DateTime.Now }; return(PartialView("AddWorkTimeLog", _twlModel)); }