public IActionResult CreateJob(CleaningEditModel model)
        {
            if (ModelState.IsValid)
            {
                if (CleaningItemImp.Exist(model.TeamId, model.ServiceRequestId))
                {
                    ViewBag.Message = "these job exist";
                }
                else
                {
                    var p = new CleaningItem()
                    {
                        ServiceRequest = ServiceRequestImp.Get(model.ServiceRequestId),
                        Team           = TeamRepository.Get(model.TeamId),
                        Description    = model.Description,
                        Created        = DateTime.Parse(model.Created),
                        Status         = "Assigned"
                    };

                    CleaningItemImp.Add(p);
                    CleaningItemImp.Commit();
                    ModelState.Clear();
                    HttpContext.Session.SetString("JobSucces", "Successfully Created a job");
                    return(RedirectToAction("CreateJob"));
                }
            }
            CleaningEditModel pq = new CleaningEditModel()
            {
                job  = new SelectList(ServiceRequestImp.GetRequest(), "Id", "RequestName"),
                team = new SelectList(TeamRepository.GetAll(), "Id", "name")
            };

            return(View(pq));
        }
        public IActionResult EditJob(CleaningEditModel model, int id)
        {
            if (ModelState.IsValid)
            {
                var k = new CleaningItem
                {
                    Id             = id,
                    ServiceRequest = ServiceRequestImp.Get(model.ServiceRequestId),
                    Team           = TeamRepository.Get(model.TeamId),
                    Description    = model.Description,
                    Created        = DateTime.Parse(model.Created),
                    Status         = model.Status
                };

                CleaningItemImp.Update(k);
                CleaningItemImp.Commit();
                return(RedirectToAction("ViewJob"));
            }
            CleaningEditModel pq = new CleaningEditModel()
            {
                job  = new SelectList(ServiceRequestImp.GetRequest(), "Id", "RequestName"),
                team = new SelectList(TeamRepository.GetAll(), "Id", "name")
            };

            return(View());
        }
Exemplo n.º 3
0
 public void Update(CleaningItem po)
 {
     _context.Entry(po).State = EntityState.Modified;
 }
Exemplo n.º 4
0
 public void Update(CleaningItem value)
 {
     _context.Entry(value).State = EntityState.Modified;
 }
Exemplo n.º 5
0
 public void Delete(CleaningItem value)
 {
     _context.CleaningItem.Remove(value);
 }
Exemplo n.º 6
0
 public void Add(CleaningItem value)
 {
     _context.CleaningItem.Add(value);
 }