// AdminCustomModel METHODS public int Insert_Admin(AdminCustomModel model) { tbl_Admin admin = model.Admin; //AdminCustomModel image_path = model.UserImageFiles; int id = AdminSecurityDB_Obj.Insert(admin); return(id); }
public ActionResult AdminEdit(AdminCustomModel Admin_OBJ) { try { if (ModelState.IsValid) { if (Admin_OBJ.UserImageFiles != null) { //image name lay rai hn string fileName = Path.GetFileNameWithoutExtension(Admin_OBJ.UserImageFiles.FileName); //image extension string Extension = Path.GetExtension(Admin_OBJ.UserImageFiles.FileName); //unique name fileName = fileName + DateTime.Now.ToString("yymmssff") + Extension; //saving path to db Admin_OBJ.Admin.ImagePath = "/images/" + fileName; //creating path from computer path + file name fileName = Path.Combine(Server.MapPath("/images/"), fileName); //obj.userimageFile mai jo image a rai hai usko save kr do folder mai Admin_OBJ.UserImageFiles.SaveAs(fileName); } if (Admin_OBJ.Admin.ImagePath == null) { Admin_OBJ.Admin.ImagePath = "/images/No_Image_Available.jpg"; } Common_Mapping_model_obj.Update_Admin(Admin_OBJ); TempData["Recored_Edited"] = "REOCORD EDITED SUCCESSFULLY"; } } catch (Exception e) { TempData["Recored_Edited"] = "REOCORD IS NOT EDITED " + e.Message; } return(RedirectToAction("AdminEdit", "Admin", new { area = "Admin" })); }
public ActionResult AdminCreate(AdminCustomModel Admin_OBJ) { try { if (ModelState.IsValid) { if (Admin_OBJ.UserImageFiles != null) { //image name lay rai hn string fileName = Path.GetFileNameWithoutExtension(Admin_OBJ.UserImageFiles.FileName); //image extension string Extension = Path.GetExtension(Admin_OBJ.UserImageFiles.FileName); //unique name fileName = fileName + DateTime.Now.ToString("yymmssff") + Extension; //saving path to db Admin_OBJ.Admin.ImagePath = "/images/" + fileName; //creating path from computer path + file name fileName = Path.Combine(Server.MapPath("/images/"), fileName); //obj.userimageFile mai jo image a rai hai usko save kr do folder mai Admin_OBJ.UserImageFiles.SaveAs(fileName); } int id = Common_Mapping_model_obj.Insert_Admin(Admin_OBJ); if (id > 0) { TempData["Adim_Created"] = "Role Created Successfully"; } } } catch (Exception e) { TempData["Adim_Not_Created"] = "There Is A Prabblem In Adding New Role" + e.Message; } return(RedirectToAction("AdminCreate", "Admin", new { area = "Admin" })); }
public void Update_Admin(AdminCustomModel model) { tbl_Admin admin = model.Admin; AdminSecurityDB_Obj.Upadate(admin); }