public ActionResult Create(AssetCategoryModel assetCategoryModel) { try { if (ModelState.IsValid) { _assetCategoryService.CreateAssetCategory(assetCategoryModel); TempData["Message"] = "Asset Category created successfully."; TempData["MessageType"] = (int)AlertMessageTypes.Success; return(RedirectToAction("List")); } else { return(View(assetCategoryModel)); } } catch (Exception e) { _logger.Error(e); TempData["Message"] = "Internal server error. Asset Category not created. Please contact administrator."; TempData["MessageType"] = (int)AlertMessageTypes.Danger; return(View(assetCategoryModel)); } }
public int UpdateAssetCategory(AssetCategoryModel assetCategoryModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("AssetCategory", "AssetCategoryName", assetCategoryModel.AssetCategoryName, assetCategoryModel.Id.ToString()); if (result > 0) { return(-1); } con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "UPDATE AssetCategory SET AssetCategoryName =@AssetCategoryName," + "Notes = @Notes, " + "UserIdUpdated = " + LoginInfo.Userid + ",DateUpdated=GetUtcDate() " + "WHERE Id = @Id;"; result = con.Execute(query, assetCategoryModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("AssetCategory"); } else { sqltrans.Rollback(); } } return(result); }
public int CreateAssetCategory(AssetCategoryModel assetCategoryModel) { AssetCategory assetCategory = null; assetCategory = this._assetCategoryRepository.CreateAssetCategory(new AssetCategory() { Description = assetCategoryModel.Description, Comment = assetCategoryModel.Comment }); return(assetCategory.ID); }
public int UpdateAssetCategory(AssetCategoryModel assetCategoryModel) { AssetCategory assetCategory = _assetCategoryRepository.GetAssetCategoryByID(assetCategoryModel.ID); if (assetCategory != null) { assetCategory.Description = assetCategoryModel.Description; assetCategory.Comment = assetCategoryModel.Comment; } _assetCategoryRepository.UpdateAssetCategory(assetCategory); return(assetCategory.ID); }
public static AssetCategory ToEntity(this AssetCategoryModel model) { return(new AssetCategory { Id = model.Id, AssetId = model.AssetId, CategoryId = model.CategoryId, CreateUserId = model.CreateUserId, CreateDate = model.CreateDate, ModifyUserId = model.ModifyUserId, ModifyDate = model.ModifyDate, StatusId = model.StatusId }); }
public ActionResult AssetCategory(int?id) { AssetCategoryModel assetCategoryModel = new AssetCategoryModel(); if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true) { if (id > 0) { assetCategoryModel = _iAssetCategoryService.GetAssetCategoryById(Convert.ToInt32(id)); } return(View(assetCategoryModel)); } else { return(RedirectToAction("NotFound", "Error")); } }
private AssetCategoryModel AddRelationShip(Guid assetId, Guid categoryId) { try { var assetCategoryModel = new AssetCategoryModel { Id = Guid.NewGuid(), AssetId = assetId, CategoryId = categoryId }; _repo.AssetCategory.Create(assetCategoryModel.ToEntity()); _repo.Save(); return(assetCategoryModel); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <IActionResult> AssetCategoryAdd(AssetCategoryModel model) { if (ModelState.IsValid) { var categoryObj = _mapper.Map <AssetCategory>(model); categoryObj.ClientId = (int)_workContext.CurrentCustomer.ClientId; var result = await _productMangement.InsertAssetCategory(categoryObj); if (result) { SuccessNotification("The asset category data has been saved successfully."); return(RedirectToAction("AssetCategoryAdd")); } else { ModelState.AddModelError("", "Something went wrong while saving record"); } } return(View(model)); }
public async Task <IActionResult> EditAssetCategory(AssetCategoryModel model) { if (ModelState.IsValid) { var catObj = _mapper.Map <AssetCategory>(model); catObj.ClientId = (int)_workContext.CurrentCustomer.ClientId; var result = await _productMangement.UpdateAssetCategory(catObj); if (result) { SuccessNotification("The asset category data has been updated successfully."); return(RedirectToAction("EditAssetCategory", "ProductManagement", new { Area = "Administration", AssetCategoryID = model.AssetCategoryId })); } else { ModelState.AddModelError("", "Something went wrong while saving record"); } } return(View(model)); }
public int InsertAssetCategory(AssetCategoryModel assetCategoryModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("AssetCategory", "AssetCategoryName", assetCategoryModel.AssetCategoryName, assetCategoryModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("AssetCategory"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO AssetCategory (Id, AssetCategoryName," + "Notes, " + "UserIdInserted,DateInserted,IsDeleted)" + "VALUES (" + MaxId + ",@AssetCategoryName," + "@Notes," + LoginInfo.Userid + ",GetUtcDate(),0); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, assetCategoryModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("AssetCategory"); } else { sqltrans.Rollback(); } return(result); } }
public ActionResult AssetCategory(AssetCategoryModel assetCategoryModel) { if (assetCategoryModel.Id > 0) { var result = _iAssetCategoryService.UpdateAssetCategory(assetCategoryModel); if (result == -1) { ModelState.AddModelError("AssetCategoryName", "Asset category already exists"); return(View(assetCategoryModel)); } ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss"); } else { var result = _iAssetCategoryService.InsertAssetCategory(assetCategoryModel); if (result == -1) { ModelState.AddModelError("AssetCategoryName", "Asset category already exists"); return(View(assetCategoryModel)); } ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess"); } return(RedirectToAction("Index", "AssetCategory")); }
public int UpdateAssetCategory(AssetCategoryModel assetCategoryModel) { return(iAssetCategoryRepository.UpdateAssetCategory(assetCategoryModel)); }
public int InsertAssetCategory(AssetCategoryModel assetCategoryModel) { return(iAssetCategoryRepository.InsertAssetCategory(assetCategoryModel)); }
public ActionResult InsertAssetCategoryFormData(AssetCategoryModel ACM) { // check type string typ = ""; con.Open(); string qq1 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " "; SqlDataAdapter daa = new SqlDataAdapter(qq1, con); DataTable dtt = new DataTable(); daa.Fill(dtt); con.Close(); if (dtt.Rows.Count > 0) { typ = dtt.Rows[0]["Type"].ToString(); } //end if (typ == "Testator") { // check will status con.Open(); string qry1 = "select Will from users where Will = 1 "; SqlDataAdapter daa1 = new SqlDataAdapter(qry1, con); DataTable dtt1 = new DataTable(); daa1.Fill(dtt1); if (dtt1.Rows.Count > 0) { ViewBag.documentbtn1 = "true"; } con.Close(); //end // check codocil status con.Open(); string qry2 = "select Codocil from users where Codocil = 1 "; SqlDataAdapter daa2 = new SqlDataAdapter(qry2, con); DataTable dtt2 = new DataTable(); daa2.Fill(dtt2); if (dtt2.Rows.Count > 0) { ViewBag.documentbtn2 = "true"; } con.Close(); //end // check Poa status con.Open(); string qry4 = "select POA from users where POA = 1 "; SqlDataAdapter daa4 = new SqlDataAdapter(qry4, con); DataTable dtt4 = new DataTable(); daa4.Fill(dtt4); if (dtt4.Rows.Count > 0) { ViewBag.documentbtn3 = "true"; } con.Close(); //end // check gift deeds status con.Open(); string qry3 = "select Giftdeeds from users where Giftdeeds = 1 "; SqlDataAdapter daa3 = new SqlDataAdapter(qry3, con); DataTable dtt3 = new DataTable(); daa3.Fill(dtt3); if (dtt3.Rows.Count > 0) { ViewBag.documentbtn4 = "true"; } con.Close(); //end } else { ViewBag.showtitle = "true"; ViewBag.documentlink = "true"; } // roleassignment List <LoginModel> Lmlist = new List <LoginModel>(); con.Open(); string q = "select * from Assignment_Roles where RoleId = " + Convert.ToInt32(Session["rId"]) + ""; SqlDataAdapter da3 = new SqlDataAdapter(q, con); DataTable dt3 = new DataTable(); da3.Fill(dt3); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { LoginModel lm = new LoginModel(); lm.PageName = dt3.Rows[i]["PageName"].ToString(); lm.PageStatus = dt3.Rows[i]["PageStatus"].ToString(); lm.Action = dt3.Rows[i]["Action"].ToString(); lm.Nav1 = dt3.Rows[i]["Nav1"].ToString(); lm.Nav2 = dt3.Rows[i]["Nav2"].ToString(); Lmlist.Add(lm); } ViewBag.PageName = Lmlist; } con.Close(); //end con.Open(); string query1 = "select count(*) from assetscategory where AssetsCategory = '" + ACM.assetcategory + "' and assetsCode = '" + ACM.assetcode + "'"; SqlCommand cmd2 = new SqlCommand(query1, con); int count = (int)cmd2.ExecuteScalar(); con.Close(); if (count > 0) { ViewBag.Message = "Duplicate"; } else { con.Open(); SqlCommand cmd = new SqlCommand("SP_AssetsCategoryCRUD", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@condition", "insert"); cmd.Parameters.AddWithValue("@atid", ACM.assettypeid); cmd.Parameters.AddWithValue("@assetcategory", ACM.assetcategory); cmd.Parameters.AddWithValue("@assetcode", ACM.assetcode); cmd.ExecuteNonQuery(); con.Close(); con.Open(); string query = "select top 1 * from AssetsCategory order by amId desc"; SqlDataAdapter da = new SqlDataAdapter(query, con); DataTable dt = new DataTable(); da.Fill(dt); if (Session["amId"] == null) { RedirectToAction("LoginPageIndex", "LoginPage"); } if (dt.Rows.Count > 0) { string i = dt.Rows[0]["atId"].ToString(); string j = dt.Rows[0]["assetsCode"].ToString(); Session["assetCodes"] = j; Session["amId"] = i; } con.Close(); ModelState.Clear(); ViewBag.Message = "Verified"; } return(View("~/Views/AddAssetCategory/AddAssetCategoryPageContent.cshtml")); }
// GET: UpdateAssetCategory public ActionResult UpdateAssetCategoryIndex(int NestId) { if (Session["rId"] == null || Session["uuid"] == null) { RedirectToAction("LoginPageIndex", "LoginPage"); } // check type string typ = ""; con.Open(); string qq1 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " "; SqlDataAdapter daa = new SqlDataAdapter(qq1, con); DataTable dtt = new DataTable(); daa.Fill(dtt); con.Close(); if (dtt.Rows.Count > 0) { typ = dtt.Rows[0]["Type"].ToString(); } //end if (typ == "Testator") { con.Open(); string qq12 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " and designation = 1 "; SqlDataAdapter da42 = new SqlDataAdapter(qq12, con); DataTable d4t2 = new DataTable(); da42.Fill(d4t2); con.Close(); if (d4t2.Rows.Count > 0) { ViewBag.documentlink = "true"; } // check will status con.Open(); string qry1 = "select Will from users where Will = 1 "; SqlDataAdapter daa1 = new SqlDataAdapter(qry1, con); DataTable dtt1 = new DataTable(); daa1.Fill(dtt1); if (dtt1.Rows.Count > 0) { ViewBag.documentbtn1 = "true"; } con.Close(); //end // check codocil status con.Open(); string qry2 = "select Codocil from users where Codocil = 1 "; SqlDataAdapter daa2 = new SqlDataAdapter(qry2, con); DataTable dtt2 = new DataTable(); daa2.Fill(dtt2); if (dtt2.Rows.Count > 0) { ViewBag.documentbtn2 = "true"; } con.Close(); //end // check Poa status con.Open(); string qry4 = "select POA from users where POA = 1 "; SqlDataAdapter daa4 = new SqlDataAdapter(qry4, con); DataTable dtt4 = new DataTable(); daa4.Fill(dtt4); if (dtt4.Rows.Count > 0) { ViewBag.documentbtn3 = "true"; } con.Close(); //end // check gift deeds status con.Open(); string qry3 = "select Giftdeeds from users where Giftdeeds = 1 "; SqlDataAdapter daa3 = new SqlDataAdapter(qry3, con); DataTable dtt3 = new DataTable(); daa3.Fill(dtt3); if (dtt3.Rows.Count > 0) { ViewBag.documentbtn4 = "true"; } con.Close(); //end } else { ViewBag.showtitle = "true"; ViewBag.documentlink = "true"; } if (Session["rId"] == null || Session["uuid"] == null) { RedirectToAction("LoginPageIndex", "LoginPage"); } //if (Session["tid"]== null) //{ // ViewBag.message = "link"; //} List <LoginModel> Lmlist = new List <LoginModel>(); con.Open(); string q = "select * from Assignment_Roles where RoleId = " + Convert.ToInt32(Session["rId"]) + ""; SqlDataAdapter da3 = new SqlDataAdapter(q, con); DataTable dt3 = new DataTable(); da3.Fill(dt3); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { LoginModel lm = new LoginModel(); lm.PageName = dt3.Rows[i]["PageName"].ToString(); lm.PageStatus = dt3.Rows[i]["PageStatus"].ToString(); lm.Action = dt3.Rows[i]["Action"].ToString(); lm.Nav1 = dt3.Rows[i]["Nav1"].ToString(); lm.Nav2 = dt3.Rows[i]["Nav2"].ToString(); Lmlist.Add(lm); } ViewBag.PageName = Lmlist; } con.Close(); AssetCategoryModel ATM = new AssetCategoryModel(); con.Open(); string query = "select * from AssetsCategory where amId = '" + NestId + "' "; SqlDataAdapter da = new SqlDataAdapter(query, con); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); if (dt.Rows.Count > 0) { ATM.amid = NestId; ATM.assetcategory = dt.Rows[0]["AssetsCategory"].ToString(); ATM.assetcode = dt.Rows[0]["assetscode"].ToString(); } return(View("~/Views/UpdateAssetCategory/UpdateAssetCategoryPageContent.cshtml", ATM)); }
public ActionResult UpdatingAssetTypes(AssetCategoryModel ACM) { // check type string typ5 = ""; con.Open(); string qq15 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " "; SqlDataAdapter daa5 = new SqlDataAdapter(qq15, con); DataTable dtt5 = new DataTable(); daa5.Fill(dtt5); con.Close(); if (dtt5.Rows.Count > 0) { typ5 = dtt5.Rows[0]["Type"].ToString(); } //end if (typ5 == "Testator") { // check will status con.Open(); string qry1 = "select Will from users where Will = 1 "; SqlDataAdapter daa1 = new SqlDataAdapter(qry1, con); DataTable dtt1 = new DataTable(); daa1.Fill(dtt1); if (dtt1.Rows.Count > 0) { ViewBag.documentbtn1 = "true"; } con.Close(); //end // check codocil status con.Open(); string qry2 = "select Codocil from users where Codocil = 1 "; SqlDataAdapter daa2 = new SqlDataAdapter(qry2, con); DataTable dtt2 = new DataTable(); daa2.Fill(dtt2); if (dtt2.Rows.Count > 0) { ViewBag.documentbtn2 = "true"; } con.Close(); //end // check Poa status con.Open(); string qry4 = "select POA from users where POA = 1 "; SqlDataAdapter daa4 = new SqlDataAdapter(qry4, con); DataTable dtt4 = new DataTable(); daa4.Fill(dtt4); if (dtt4.Rows.Count > 0) { ViewBag.documentbtn3 = "true"; } con.Close(); //end // check gift deeds status con.Open(); string qry3 = "select Giftdeeds from users where Giftdeeds = 1 "; SqlDataAdapter daa3 = new SqlDataAdapter(qry3, con); DataTable dtt3 = new DataTable(); daa3.Fill(dtt3); if (dtt3.Rows.Count > 0) { ViewBag.documentbtn4 = "true"; } con.Close(); //end } else { ViewBag.documentlink = "true"; } // roleassignment List <LoginModel> Lmlist = new List <LoginModel>(); con.Open(); string q = "select * from Assignment_Roles where RoleId = " + Convert.ToInt32(Session["rId"]) + ""; SqlDataAdapter da3 = new SqlDataAdapter(q, con); DataTable dt3 = new DataTable(); da3.Fill(dt3); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { LoginModel lm = new LoginModel(); lm.PageName = dt3.Rows[i]["PageName"].ToString(); lm.PageStatus = dt3.Rows[i]["PageStatus"].ToString(); lm.Action = dt3.Rows[i]["Action"].ToString(); lm.Nav1 = dt3.Rows[i]["Nav1"].ToString(); lm.Nav2 = dt3.Rows[i]["Nav2"].ToString(); Lmlist.Add(lm); } ViewBag.PageName = Lmlist; } con.Close(); //end con.Open(); SqlCommand cmd = new SqlCommand("SP_AssetsCategoryCRUD", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@condition", "update"); cmd.Parameters.AddWithValue("@amId", ACM.amid); cmd.Parameters.AddWithValue("@assetcategory", ACM.assetcategory); cmd.Parameters.AddWithValue("@assetcode", ACM.assetcode); cmd.Parameters.AddWithValue("@atid", ""); cmd.ExecuteNonQuery(); con.Close(); ViewBag.Message = "Verified"; return(View("~/Views/UpdateAssetCategory/UpdateAssetCategoryPageContent.cshtml")); }