public HttpResponseMessage GetPlantList() { List <ENT.PlantMasterSUB> lstResult = new List <ENT.PlantMasterSUB>(); try { if (User.IsInRole("Administrator")) { lstResult = new BAL.PlantMasterBAL().GetPlantList(); } else if (User.IsInRole("Admin")) { lstResult = new BAL.PlantMasterBAL().GetPlantListByUser(User.GetLogged_Userid()); } else { using (BAL.PlantMasterBAL obj = new Josheph.Framework.BusinessLayer.PlantMasterBAL()) { obj.Entity = new Josheph.Framework.Entity.PlantMasterSUB(); obj.Entity.AspNetUserID = User.GetLogged_Userid(); obj.Entity = (ENT.PlantMasterSUB)obj.GetByLoginID(obj.Entity); lstResult.Add(obj.Entity); } } } catch (Exception ex) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.InternalServerError, new { lstResult })); } return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { lstResult })); }
public ActionResult Index() { ViewBag.PlantMaster = new BAL.PlantMasterBAL().GetAll(string.Empty, 1, 0); using (BAL.PlantMasterBAL obj = new Josheph.Framework.BusinessLayer.PlantMasterBAL()) { obj.Entity = new Josheph.Framework.Entity.PlantMasterSUB(); obj.Entity.AspNetUserID = User.GetLogged_Userid(); obj.Entity = (ENT.PlantMasterSUB)obj.GetByLoginID(obj.Entity); if (obj.Entity != null) { ViewBag.PlantName = obj.Entity.PlantName; } } return(View()); }
[Authorize]//Save Entry public JsonResult SaveEntry(ENT.PlantMasterSUB model, string PlantId) { try { List <Guid> dctDuplication = new List <Guid>(); if (model.InstallationSize.ToString() == "0") { throw new Exception("Please Select Installation Size."); } if (model.InstallationType.ToString() == "0") { throw new Exception("Please Select Installation Type."); } //if (model.CountryID.ToString() == "00000000-0000-0000-0000-000000000000") { throw new Exception("Please Select Country."); } //if (model.StateID.ToString() == "00000000-0000-0000-0000-000000000000") { throw new Exception("Please Select State."); } if (model.CityID.ToString() == "00000000-0000-0000-0000-000000000000") { throw new Exception("Please Select City."); } if (model.EntryMode == COM.MyEnumration.EntryMode.ADD) { model.Status = COM.MyEnumration.MyStatus.Active; List <ENT.PlantMasterSUB> lstResult = new BAL.PlantMasterBAL().CheckDuplicateCombination(dctDuplication, COM.MyEnumration.MasterType.PlantMaster, model.PlantName, model.ContactPerson, model.Mobile, model.EmailId); if (lstResult.Count > 0) { throw new Exception("Plant Name Already Exists."); } List <ENT.PlantMasterSUB> lstResult2 = new BAL.PlantMasterBAL().CheckDuplicateMobile(dctDuplication, COM.MyEnumration.MasterType.PlantMaster, model.PlantName, model.ContactPerson, model.Mobile, model.EmailId); if (lstResult2.Count > 0) { throw new Exception("Mobile No Already Exists.!"); } List <ENT.PlantMasterSUB> lstResult3 = new BAL.PlantMasterBAL().CheckDuplicateEmail(dctDuplication, COM.MyEnumration.MasterType.PlantMaster, model.PlantName, model.ContactPerson, model.Mobile, model.EmailId); if (lstResult3.Count > 0) { GlobalVarible.AddError("Email Id Already Exists.!"); } var user = new ApplicationUser { UserName = model.EmailId, Email = model.EmailId }; IdentityResult result = UserManager.Create(user, model.Password); if (result.Succeeded) { this.UserManager.AddToRoleAsync(user.Id, "Client"); model.CreatedBy = User.GetLogged_Userid(); model.AspNetUserID = Guid.Parse(user.Id); if (objBAL.Insert(model)) { GlobalVarible.AddMessage("Record Save Successfully"); } } else { foreach (var e in result.Errors) { GlobalVarible.AddError(e); } } } else { model.CreatedDateTime = DateTime.Now; model.PlantId = new Guid(PlantId.Replace("/", "")); if (objBAL.Update(model)) { GlobalVarible.AddMessage("Record Update Successfully"); } } } catch (Exception ex) { GlobalVarible.AddError(ex.Message); } MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML(); return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet)); }