public ActionResult Save(EmbFirmLocationVM oEmbFirmLocationVM) { bool Add_Flag = new CommonBL().isNewEntry(oEmbFirmLocationVM.EmbroideryFirmId); try { if (Add_Flag) { EmbroideryFirmLocation oEmbroideryFirmLocation = new EmbroideryFirmLocation(); oEmbroideryFirmLocation.EmbroideryFirmLocationId = Guid.NewGuid(); oEmbroideryFirmLocation.JariCompanyId = oJariCompany.JariCompanyId; oEmbroideryFirmLocation.ContactPerson = oEmbFirmLocationVM.ContactPerson; oEmbroideryFirmLocation.Address1 = oEmbFirmLocationVM.Address1; oEmbroideryFirmLocation.Address2 = oEmbFirmLocationVM.Address2; oEmbroideryFirmLocation.City = oEmbFirmLocationVM.City; oEmbroideryFirmLocation.IsPrimaryLocation = true; oEmbroideryFirmLocation.Status = true; oEmbroideryFirmLocation.Phone = oEmbFirmLocationVM.Phone; oEmbroideryFirmLocation.Email = oEmbFirmLocationVM.Email; oEmbroideryFirmLocation.BillingTerms = oEmbFirmLocationVM.BillingTerms; oEmbroideryFirmLocation.ModifiedBy = oUser.Email; oEmbroideryFirmLocation.ModifiedOn = DateTime.UtcNow; EmbroideryFirm oEmbroideryFirm = new EmbroideryFirm(); oEmbroideryFirm.EmbroideryFirmId = Guid.NewGuid(); oEmbroideryFirm.JariCompanyId = oJariCompany.JariCompanyId; oEmbroideryFirm.IsActive = oEmbFirmLocationVM.IsActive; oEmbroideryFirm.EmbroideryFirmName = oEmbFirmLocationVM.EmbroideryFirmName; oEmbroideryFirm.ModifiedBy = oUser.Email; oEmbroideryFirm.ModifiedOn = DateTime.UtcNow; //Add location with EmbroideryFirm object oEmbroideryFirm.EmbroideryFirmLocations.Add(oEmbroideryFirmLocation); new EmbroideryFirmBL().Create(oEmbroideryFirm); } else { EmbroideryFirm oEmbroideryFirm = new EmbroideryFirm(); oEmbroideryFirm.EmbroideryFirmId = oEmbFirmLocationVM.EmbroideryFirmId; oEmbroideryFirm.JariCompanyId = oJariCompany.JariCompanyId; oEmbroideryFirm.IsActive = oEmbFirmLocationVM.IsActive; oEmbroideryFirm.EmbroideryFirmName = oEmbFirmLocationVM.EmbroideryFirmName; oEmbroideryFirm.ModifiedBy = oUser.Email; oEmbroideryFirm.ModifiedOn = DateTime.UtcNow; new EmbroideryFirmBL().Update(oEmbroideryFirm); } TempData["successmsg"] = CommonMsg.Success(EntityNames.EmbroideryFirm, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update); //return RedirectToAction("ViewDetail", new { id = oEmbFirmLocationVM.EmbroideryFirmId.ToString().ToUpper(), tab = "EmbroideryFirmDetail" }); return(RedirectToAction("Index")); } catch (Exception) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.EmbroideryFirm, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } }
public ActionResult Manage(Guid?id) { List <SelectListItem> lstterms = new List <SelectListItem>(); foreach (var e in Enum.GetValues(typeof(En_Billing_Terms))) { SelectListItem obj = new SelectListItem(); obj.Text = e.ToString().Replace("_", ""); obj.Value = e.ToString().Replace("_", ""); lstterms.Add(obj); } ViewBag.lstBillingTerms = lstterms; EmbFirmLocationVM oEmbFirmLocationVM = new EmbFirmLocationVM(); oEmbFirmLocationVM.City = "Surat"; //Default City oEmbFirmLocationVM.JariCompanyId = oJariCompany.JariCompanyId; if (id != null) { EmbroideryFirm oEmbroideryFirm = new EmbroideryFirmBL().GetById(id.Value); oEmbFirmLocationVM.EmbroideryFirmId = oEmbroideryFirm.EmbroideryFirmId; oEmbFirmLocationVM.JariCompanyId = oEmbroideryFirm.JariCompanyId; oEmbFirmLocationVM.IsActive = oEmbroideryFirm.IsActive; oEmbFirmLocationVM.EmbroideryFirmName = oEmbroideryFirm.EmbroideryFirmName; //oEmbFirmLocationVM.LocationContact =""; //oEmbFirmLocationVM.Address1 = ""; //oEmbFirmLocationVM.Address2 = ""; //oEmbFirmLocationVM.City = ""; //oEmbFirmLocationVM.IsPrimaryLocation = true; //oEmbFirmLocationVM.Status = true; //oEmbFirmLocationVM.Phone = ""; //oEmbFirmLocationVM.Email = ""; //oEmbFirmLocationVM.BillingTerms = 1; //oEmbFirmLocationVM.Latitude = 100; //oEmbFirmLocationVM.Longitude = 100; } return(View(oEmbFirmLocationVM)); }