public int ChangeStatus(int orderId, string userId, StatusTypeVM status) { try { Order order = _orderRepository.GetById(orderId); User user = _userRepository.GetById(userId); //order.Status = status; order.Status = (StatusType)status; if (status == StatusTypeVM.Pending) { _orderRepository.Insert( new Order { User = user, DateOfOrder = DateTime.Now, Status = StatusType.Init } ); } return(_orderRepository.Update(order)); } catch (Exception ex) { string message = ex.Message; throw new Exception(message); } }
public ActionResult Create(StatusTypeVM v) { if (ModelState.IsValid) { tblStatusType d = new tblStatusType(); int max = (from c in db.tblStatusTypes orderby c.ID descending select c.ID).FirstOrDefault(); if (max == null) { d.ID = 1; d.Name = v.Name; d.Code = v.Code; } else { d.ID = max + 1; d.Name = v.Name; d.Code = v.Code; } db.tblStatusTypes.Add(d); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully added Status Type."; return(RedirectToAction("Index")); } return(View()); }
/// <summary> /// this is for only enum type parse. /// </summary> /// <param name="TypeChanger"></param> /// <returns></returns> private StatusTypeVM TypeChanger(StatusType statusType) { _logger.LogInformation("TypeChanger called."); StatusTypeVM statusTypeVM = StatusTypeVM.Deployable; Enum.TryParse <StatusTypeVM>(statusTypeVM.ToString(), out statusTypeVM); return(statusTypeVM); }
public ActionResult Create([Bind(Include = "Name")] StatusTypeVM statusTypeVM) { if (ModelState.IsValid) { StatusTypeDTO statusTypeDTO = Mapper.Map <StatusTypeDTO>(statusTypeVM); StatusTypeService.Add(statusTypeDTO); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Edit(StatusTypeVM v) { if (ModelState.IsValid) { tblStatusType c = new tblStatusType(); c.ID = v.ID; c.Name = v.Name; c.Code = v.Code; db.Entry(c).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully updated Status Type."; return(RedirectToAction("Index")); } return(View()); }
public ActionResult Edit(int id) { StatusTypeVM v = new StatusTypeVM(); var x = db.tblStatusTypes.Find(id); if (x == null) { return(HttpNotFound()); } else { v.ID = x.ID; v.Name = x.Name; v.Code = x.Code; } return(View(v)); }
public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StatusTypeDTO statusTypeDTO = StatusTypeService.Get((Guid)id); if (statusTypeDTO == null) { return(HttpNotFound()); } StatusTypeVM statusTypeVM = Mapper.Map <StatusTypeVM>(statusTypeDTO); return(View(statusTypeVM)); }
public ActionResult Index() { List <StatusTypeVM> lst = new List <StatusTypeVM>(); var data = db.tblStatusTypes.ToList(); foreach (var item in data) { StatusTypeVM a = new StatusTypeVM(); a.ID = item.ID; a.Name = item.Name; a.Code = item.Code; lst.Add(a); } return(View(lst)); }