public async Task <ActionResult> saveJob(int EmployeeId, int stitchingjobid) { if (HttpContext.Session.GetString("Id") == null) { HttpContext.Session.Clear(); return(RedirectToAction("Index", "Account")); } //get from barcode or from input field Users user = _context.Users.Find(Convert.ToInt32(HttpContext.Session.GetString("Id"))); StitchingUnitDepartmentHead sudh = (from s in _context.StitchingUnitDepartmentHead where s.Id == user.Id select s).ToList()[0]; var pa = (from p in _context.ProductionActivity where p.StitchingJobId == stitchingjobid && p.ProgressStatus == sudh.AssociatedDepartmentId select p); if (pa.Any()) { TempData["alreadyadded"] = true; return(RedirectToAction("ProcessJobRole")); } int stitchingstatus = sudh.AssociatedDepartmentId; //get from session based on which deparment head is stitching unit deparment head await new SaveProductionActivity().logProductionActivity(_context, EmployeeId, stitchingjobid, stitchingstatus); SendSms(stitchingjobid); TempData["stitchingjobsave"] = true; //get Current User from Session return(RedirectToAction("ProcessJobRole")); }
public async Task addstdp(MadeToMeasureContext context, string name, string id, DateTime date, string password, int entitycode, int deprtmentcode) { Users user = new Users(); user.WorksAt = entitycode; user.UserId = id; user.UserType = 5; user.Password = password; user.JoiningDate = date; user.Name = name; context.Users.Add(user); await context.SaveChangesAsync(); var a = from k in context.Users where k.UserId == id select k.Id; int idd = 0; // b.EntityAddress = address; // ;/ b.EntityType = 3; foreach (var b in a) { idd = (int)b; StitchingUnitDepartmentHead sthead = new StitchingUnitDepartmentHead(); sthead.Id = idd; sthead.AssociatedDepartmentId = deprtmentcode; context.StitchingUnitDepartmentHead.Add(sthead); } await context.SaveChangesAsync(); }