public ActionResult CreateTechnicalSupport(TechnicalSupportModel entity) { if (_TechnicalSupportManager.getByID(entity.VisitedDate,entity.CustomerID,User.Identity.Name)!=null) { ModelState.AddModelError("*", "This Customer and Visited date are duplicated in record."); return View(new TechnicalSupportModel { CustomerID = entity.CustomerID }).WithErrorMessage("Duplicated record!"); } try { // TODO: Add insert logic here entity.AttachGroupID = Guid.NewGuid(); entity.CreatedBy = User.Identity.Name; entity.CreatedDate = DateTime.Today; _TechnicalSupportManager.Save(entity); List<FileAttachmentModel> FAList = (List<FileAttachmentModel>)Session["Attachment"]; if (FAList != null) { foreach (FileAttachmentModel item in FAList) { _FileAttachmentManager.Save(item,entity.AttachGroupID,User.Identity.Name); } } return RedirectToAction("Index"); } catch (Exception ex) { var modal = new HandleErrorInfo(ex, "TechnicalSupport", "CreateTechnicalSupport"); return View("Error", modal); } }
public void Save(TechnicalSupportModel entity) { objTecnicalSupport = new CRM_TechnicalSupportRepository(); Mapper.CreateMap<TechnicalSupportModel, CRM_TechnicalSupport>(); CRM_TechnicalSupport objSave = new CRM_TechnicalSupport(); objSave = Mapper.Map(entity, objSave); objTecnicalSupport.Add(objSave); }
public TechnicalSupportModel getByID(DateTime visitDate, string customerID, string createdBy) { Mapper.CreateMap<CRM_TechnicalSupport, TechnicalSupportModel>(); objTecnicalSupport = new CRM_TechnicalSupportRepository(); CRM_TechnicalSupport objEntity = objTecnicalSupport.GetSingle(v => v.VisitedDate == visitDate && v.CustomerID == customerID && v.CreatedBy == createdBy); TechnicalSupportModel objResult = new TechnicalSupportModel(); objResult = Mapper.Map(objEntity, objResult); return objResult; }
public void Delete(TechnicalSupportModel entity) { objTecnicalSupport = new CRM_TechnicalSupportRepository(); if (objTecnicalSupport.GetAll(v => v.VisitedDate == entity.VisitedDate && v.CustomerID == entity.CustomerID && v.CreatedBy == entity.CreatedBy).Count() > 0) { CRM_TechnicalSupport deleteRecord = objTecnicalSupport.GetSingle(v => v.VisitedDate == entity.VisitedDate && v.CustomerID == entity.CustomerID && v.CreatedBy == entity.CreatedBy); objTecnicalSupport.Delete(deleteRecord); } }
public void Update(TechnicalSupportModel entity) { objTecnicalSupport = new CRM_TechnicalSupportRepository(); Mapper.CreateMap<TechnicalSupportModel, CRM_TechnicalSupport>(); if (objTecnicalSupport.GetAll(v => v.VisitedDate == entity.VisitedDate && v.CustomerID == entity.CustomerID && v.CreatedBy == entity.CreatedBy).Count() > 0) { CRM_TechnicalSupport updateRecord = objTecnicalSupport.GetSingle(v => v.VisitedDate == entity.VisitedDate && v.CustomerID == entity.CustomerID && v.CreatedBy == entity.CreatedBy); updateRecord = Mapper.Map(entity, updateRecord); objTecnicalSupport.Update(updateRecord); } }
public ActionResult EditTechnicalSupport(string id, DateTime visited, string createdBy, TechnicalSupportModel entity) { try { // TODO: Add update logic here entity.CustomerID = id; entity.VisitedDate = visited; entity.CreatedBy = createdBy; entity.AttachGroupID = (Guid)Session["AttachGroupID"]; entity.ModifiedBy = User.Identity.Name; entity.ModifiedDate = DateTime.Today; _TechnicalSupportManager.Update(entity); #region "Attach Saving" List<FileAttachmentModel> FAList = (List<FileAttachmentModel>)Session["Attachment"]; if (FAList != null) { foreach (FileAttachmentModel item in FAList) { _FileAttachmentManager.Delete(item, entity.AttachGroupID); _FileAttachmentManager.Save(item, entity.AttachGroupID, User.Identity.Name); } } #endregion return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult DeleteTechnicalSupport(string id, DateTime visited, string createdBy, TechnicalSupportModel entity) { try { // TODO: Add delete logic here entity.CustomerID = id; entity.VisitedDate = visited; entity.CreatedBy = createdBy; entity.AttachGroupID = (Guid)Session["AttachGroupID"]; _TechnicalSupportManager.Delete(entity); #region "Attach Saving" List<FileAttachmentModel> FAList = (List<FileAttachmentModel>)Session["Attachment"]; if (FAList != null) { foreach (FileAttachmentModel item in FAList) { var Delfile = System.IO.Path.Combine(Server.MapPath("~/UploadFiles"), item.ServerFileName); if (System.IO.File.Exists(Delfile)) { System.IO.File.Delete(Delfile); } _FileAttachmentManager.Delete(item, entity.AttachGroupID); } } #endregion return RedirectToAction("Index"); } catch { return View(); } }