public ActionResult Create(VendorSaveViewModel model) { model.VendorCategories = _entities.tbl_tblVendorCategory.ToList(); if (ModelState.IsValid) { var password = "******"; try { tbl_tblVendor obj = new tbl_tblVendor(); //Encrypted SHA Vendor Name string vendorName = Cipher.Encrypt(model.VendorName, password); obj.VendorName = vendorName; ////Encrypted Vendor Name //string vendorName = Encryption.Encrypt(model.VendorName); //obj.VendorName = vendorName; obj.VendorAddress = sanitizer.Sanitize(model.VendorAddress); obj.VendorCategory = model.VendorCategory; obj.VendorContactName = sanitizer.Sanitize(model.VendorContactName); obj.VendorPhone = sanitizer.Sanitize(model.VendorPhone); obj.VendorEmail = sanitizer.Sanitize(model.VendorEmail); obj.CreatedBy = Convert.ToInt32(Session["UserID"]); obj.CreatedOn = System.DateTime.Now; obj.IsDeleted = false; _entities.tbl_tblVendor.Add(obj); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { throw ex; } } return(View(model)); }
public ProjectViewModel SaveProject(ProjectViewModel model) { using (DbContextTransaction dbTran = _entities.Database.BeginTransaction()) { try { tbl_mst_Project Eventexists = _entities.tbl_mst_Project.Where(x => x.ProjectId == model.ProjectId && x.IsActive == "Y").FirstOrDefault(); if (Eventexists == null) { tbl_mst_Project _Project = new tbl_mst_Project { ProjectId = 0, ProjectName = model.ProjectName, TemplateType = model.TemplateType, CreatedBy = model.CreatedBy, StartDate = model.StartDate, RecInsTime = System.DateTime.Now, TempleteId = 1, CreateOn = System.DateTime.Now, IsActive = "Y" }; _entities.tbl_mst_Project.Add(_Project); _entities.SaveChanges(); dbTran.Commit(); model.Message = "Saved"; } else { Eventexists.ProjectId = model.ProjectId; Eventexists.ProjectName = model.ProjectName; Eventexists.TemplateType = model.TemplateType; Eventexists.CreatedBy = model.CreatedBy; Eventexists.StartDate = model.StartDate; _entities.SaveChanges(); dbTran.Commit(); model.Message = "Update"; } } catch (DbEntityValidationException e) { foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } model.Message = "Not"; dbTran.Rollback(); throw; } } return(model); }
public ActionResult Create(AcquisitionCreateMasterViewModel model) { if (ModelState.IsValid) { try { acq_meeting_master obj = new acq_meeting_master(); obj.dac_dpb = sanitizer.Sanitize(model.dac_dpb); obj.meeting_date = model.meeting_date; if (model != null) { obj.Date_of_Issue_of_Minutes = model.Date_of_Issue_of_Minutes; } else { obj.Date_of_Issue_of_Minutes = model.Date_of_Issue_of_Minutes; } obj.Date_of_Issue_of_Minutes = model.Date_of_Issue_of_Minutes; obj.Remarks = sanitizer.Sanitize(model.Remarks); obj.CreatedBy = Convert.ToInt32(Session["UserID"]); obj.CreatedOn = System.DateTime.Now; obj.Deleted = false; _entities.acq_meeting_master.Add(obj); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { throw ex; } } return(View()); }
public ActionResult ChangePassword(ChangePasswordViewModel model) { if (ModelState.IsValid) { try { using (var _context = new MODEntities()) { model.UserId = Convert.ToInt32(Session["UserID"]); var changePassword = _context.tbl_tbl_User.Where(x => x.Password == model.OldPassword && x.UserId == model.UserId).FirstOrDefault(); if (changePassword != null) { changePassword.Password = model.NewPassword; _context.SaveChanges(); TempData["ChangePassword"] = "******"; } } } catch (Exception ex) { throw ex; } } return(View()); }
public ActionResult Escalationmatrix(UserSaveViewModel model) { model.departmentList = _entities.acq_department_master.ToList(); model.SectionMasterList = _entities.acq_section_master.ToList(); if (ModelState.IsValid) { try { string GenPwd1 = model.Password; string GetSalt = GeneratedPassword.CreateSalt(10); string hashString = GeneratedPassword.GenarateHash(GenPwd1, GetSalt); tbl_tbl_User obj = new tbl_tbl_User(); obj.UserName = model.UserName; obj.InternalEmailID = model.InternalEmailID; obj.ExternalEmailID = model.ExternalEmailID; obj.Password = null; obj.RankUser = model.RankUser; obj.Phone = model.Phone; obj.DepartmentID = model.DepartmentID; obj.SectionID = model.SectionID; obj.ValidFrom = Convert.ToDateTime(model.ValidFrom); obj.ValidTill = Convert.ToDateTime(model.ValidTill); obj.IPAddress = model.IPAddress; obj.MacAddress = model.MacAddress; obj.Designation = model.Designation; obj.LoginAllowed = model.LoginAllowed; obj.Pswd_Salt = Encryption.Encrypt(GenPwd1); obj.Flag = "Y"; obj.LoginCount = 0; obj.CreatedBy = Convert.ToInt32(Session["UserID"]); obj.CreatedOn = System.DateTime.Now; obj.IsDeleted = false; _entities.tbl_tbl_User.Add(obj); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { throw ex; } } return(View(model)); }
public ActionResult Create(DepartmentSaveViewModel model) { if (ModelState.IsValid) { try { acq_department_master obj = new acq_department_master(); obj.deptt_description = model.DepartmentName; _entities.acq_department_master.Add(obj); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { throw ex; } } return(View()); }
public ActionResult Create(AcfpolicyviewModel model) { acq_policy obj = new acq_policy(); try { string FilePath = ""; HttpPostedFileBase fileBase = Request.Files["file"]; if (fileBase.ContentLength > 0) { byte[] fileDetails = new byte[fileBase.ContentLength]; fileBase.InputStream.Read(fileDetails, 0, fileBase.ContentLength); string fileData = Cipher.Encrypt((Convert.ToBase64String(fileDetails)), password); string[] Filenamechar = fileBase.FileName.Split('.'); Filenamechar[1] = ".txt"; string Filename = Filenamechar[0] + Filenamechar[1]; FilePath = createFile(fileData, Filename); } using (DbContextTransaction dbTran = entities.Database.BeginTransaction()) { try { int SectionID = Convert.ToInt32(Session["SectionID"]); obj.fdate = model.fdate; obj.tdate = model.tdate; obj.Remarks = sanitizer.Sanitize(Cipher.Encrypt(model.Remarks, password)); obj.aon_id = model.aon_id; obj.section_id = SectionID; obj.pdfattachment = FilePath; obj.stagid = model.stagid; //Convert.ToInt32(model.TaskSlno); obj.IsDeleted = false; entities.acq_policy.Add(obj); entities.SaveChanges(); dbTran.Commit(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } dbTran.Rollback(); throw; } } return(RedirectToAction("Index")); } catch (Exception ex) { } List <tbl_mst_Template> Templateexists = entities.tbl_mst_Template.Where(x => x.IsActive == "Y").ToList(); ViewBag.TemplateexistsData = Templateexists; model.ProjectList = TempData["ProjectList"] as List <AcfpolicyviewModel>; return(View(model)); }