public bool UpdateFirm(FirmViewModel model) { try { using (DataContext = new DmsDomainContext()) { Firm objFirm = new Firm(); objFirm = DataContext.Firms.Where(x => x.FirmId == model.FirmId).FirstOrDefault(); objFirm.FirmId = Convert.ToInt32(SessionManagement.LoggedInUser.FirmId); objFirm.FirmName = model.FirmName; objFirm.FirmEmail = model.FirmEmail; objFirm.IsActive = true; objFirm.IsDeleted = false; objFirm.ModifiedDate = DateTime.Now; objFirm.ModifiedBy = 5534534543545; objFirm.CreatedDate = DateTime.Now; objFirm.CreatedBy = 5534534543545; DataContext.SaveChanges(); return(true); } } catch (Exception ex) { throw; } }
public ActionResult Edit(int?id) { Firm firm = db.Firms.Find(id); FirmViewModel model = Mapper.Map <Firm, FirmViewModel>(firm); return(View(model)); }
public async Task <IActionResult> Edit([Required][FromRoute] int id) { if (ModelState.IsValid) { try { StaticData staticData = await lawyerDbContext.StaticDatas.FindAsync(id); FirmViewModel firmViewModel = new FirmViewModel { Id = id, Firms = (await lawyerDbContext.GetFirmViewAsync()) .Select(m => new FirmMap { Title = m.Title, Description = m.Description, LanguageId = m.LanguageId }) .OrderBy(m => m.LanguageId).ToList(), Languages = await lawyerDbContext.Languages .AsNoTracking() .ToListAsync() }; return(View(firmViewModel)); } catch { } } return(RedirectToAction(nameof(Index))); }
public ActionResult AddFirm(FirmViewModel objmodel) { if (TempData["FirmId"] != null) { objmodel = _FirmService.GetFirm(Convert.ToInt64(TempData["FirmId"])); objmodel.FirmId = Convert.ToInt64(TempData["FirmId"]); } ViewBag.Success = TempData["resultMessage"]; return(View(objmodel)); }
public FirmController(ApplicationDbContext context) { _context = context; Model = new FirmViewModel() { Sectors = _context.Sectors.Where(s => s.IsActive == true).ToList(), Firm = new Firm() }; }
public ActionResult Edit(FirmViewModel model) { if (ModelState.IsValid) { Firm firm = Mapper.Map <FirmViewModel, Firm>(model); db.Entry(firm).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(FirmViewModel model) { if (ModelState.IsValid) { Firm firm = Mapper.Map <FirmViewModel, Firm>(model); db.Firms.Add(firm); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult GetFirm(long?FirmId) { FirmViewModel objmodal = new FirmViewModel(); if (FirmId != null) { TempData["FirmId"] = FirmId.Value; //objmodal = _ClientService.GetClient(ClientId.Value); } return(Json(new { result = "Redirect", url = Url.Action("AddFirm", "Firm", new { Area = "SuperAdmin" }), objmodal })); // return RedirectToAction("AddClient", objmodal); //View("/Areas/FirmArea/Firm/AddClient.cshtml", objmodal); }
public ActionResult SaveFirm(FirmViewModel model) { if (ModelState.IsValid) { try { if (model.FirmId != 0) { model.ModifiedDate = DateTime.Now; try { bool _result = _FirmService.UpdateFirm(model); if (_result == true) { TempData["resultMessage"] = "Firm Information Updated Successfully"; } return(RedirectToAction("Dashboard")); } catch (Exception ex) { throw; } } else { model.CreatedDate = DateTime.Now; try { bool _result = _FirmService.AddFirm(model); if (_result == true) { TempData["resultMessage"] = "Firm Added Successfully"; } return(RedirectToAction("Dashboard")); } catch (Exception ex) { throw; } } //return View("AddClient"); } catch (Exception ex) { return(View("AddClient")); } } return(View("Dashboard")); }
public bool AddFirm(FirmViewModel model) { try { using (uow) { Firm objFirm = new Firm(); objFirm.FirmId = Convert.ToInt32(SessionManagement.LoggedInUser.FirmId); objFirm.FirmName = model.FirmName; objFirm.FirmEmail = model.FirmEmail; objFirm.IsActive = true; objFirm.IsDeleted = false; objFirm.CreatedDate = DateTime.Now; objFirm.CreatedBy = SessionManagement.LoggedInUser.UserId; uow.Repository <Firm>().Add(objFirm); uow.SaveChanges(); using (subuow) { User objUser = new User(); objUser.FirmID = objFirm.FirmId; objUser.UserName = model.UserName; objUser.Password = CommonFunction.EncryptPassword(model.Password); objUser.CreatedBy = SessionManagement.LoggedInUser.UserId; objUser.CreatedDate = DateTime.Now; // objIndividualClient.EmployeeId = null; // objIndividualClient.IndividualRecordId = 1; objUser.IsActive = true; objUser.IsDeleted = false; //objIndividualClient.IsIndividualClient = true; // objIndividualClient.ClientRecordId = objClient.ClientId; objUser.ModifiedBy = SessionManagement.LoggedInUser.UserId; objUser.ModifiedDate = DateTime.Now; subuow.Repository <User>().Add(objUser); subuow.SaveChanges(); } return(true); } } catch (Exception ex) { throw; } }
public FirmViewModel GetFirm(long FirmId) { var res = _IFirmRepository.GetFirm(FirmId); FirmViewModel model = new FirmViewModel(); model.FirmId = res.FirmId; model.FirmName = res.FirmEmail; model.FirmEmail = res.FirmEmail; var user = res.Users.FirstOrDefault(); if (user != null) { model.UserName = user.UserName; model.Password = user.Password; } return(model); }
public ActionResult Edit(int id, int?decissionId = null, Guid?userId = null, int?seminarId = null) { var firm = _firmRepository.GetNullableById(id); if (firm == null) { Message = string.Format(Messages.NotFound, "firm", id); return(this.RedirectToAction(a => a.Index())); } // if review, get the last one, if it exists var origFirm = firm.Review ? (_firmService.GetFirm(firm.FirmCode)) : firm; var viewModel = FirmViewModel.Create(Repository, firm, origFirm); ViewBag.DecissionId = decissionId; ViewBag.UserId = userId; ViewBag.SeminarId = seminarId; return(View(viewModel)); }
public static FirmViewModel ReadArchiveFirms() { var imported = Db.Trackings.Where(a => a.Name == _archiveFirmTable).Any(); var firms = new List <Firm>(); var errors = new List <KeyValuePair <string, string> >(); ReadData("~/Assets/Firm.xls", imported, firms, errors); if (!imported) { var tracking = new Tracking() { Name = _archiveFirmTable }; Db.Trackings.Add(tracking); Db.SaveChanges(); } var viewModel = FirmViewModel.Create(firms, errors, imported); return(viewModel); }
public ActionResult Edit(int id, Firm firm, int?decissionId = null) { ViewBag.DecissionId = decissionId; firm.Review = false; if (ModelState.IsValid) { _firmRepository.EnsurePersistent(firm); Message = string.Format(Messages.Saved, "Firm"); if (decissionId != null) { return(this.RedirectToAction <SeminarApplicationController>(a => a.Decide(decissionId.Value))); } return(this.RedirectToAction(a => a.Index())); } // if review, get the last one, if it exists var origFirm = firm.Review ? (_firmService.GetFirm(firm.FirmCode)) : firm; var viewModel = FirmViewModel.Create(Repository, firm, origFirm); return(View(viewModel)); }
public bool AddFirm(FirmViewModel model) { return(_IFirmRepository.AddFirm(model)); }
public bool UpdateFirm(FirmViewModel model) { return(_IFirmRepository.UpdateFirm(model)); }
public async Task <IActionResult> Edit([Required][FromForm] int id, FirmEditModel firmEditModel) { if (ModelState.IsValid) { IDbContextTransaction transaction = null; try { transaction = await lawyerDbContext.Database.BeginTransactionAsync(); StaticData staticData = await lawyerDbContext.StaticDatas.FindAsync(id); if (staticData == null) { throw new NullReferenceException("This firm doesn't exist. "); } if (firmEditModel.Img != null) { string fileName = staticData.OurFirmImg; staticData.OurFirmImg = await FileService.UploadImageAsync(firmEditModel.Img, "Uploads"); FileService.DeleteFile(fileName, "Uploads"); } IEnumerable <Text> titleTextAllLanguage = await lawyerDbContext.Texts .Where(m => m.Key == staticData.OurFirmTitleKey) .ToListAsync(); IEnumerable <Text> descriptionTextAllLanguage = await lawyerDbContext.Texts .Where(m => m.Key == staticData.OurFirmDescriptionKey) .ToListAsync(); //Update texts all language for properties foreach (var item in firmEditModel.Firms) { Text title = titleTextAllLanguage.SingleOrDefault(m => m.LanguageId == item.LanguageId); title.TextContent = item.Title; } foreach (var item in firmEditModel.Firms) { Text description = descriptionTextAllLanguage.SingleOrDefault(m => m.LanguageId == item.LanguageId); description.TextContent = item.Description; } await lawyerDbContext.SaveChangesAsync(); transaction.Commit(); return(RedirectToAction(nameof(Index))); } catch (NullReferenceException exp) { ModelState.AddModelError("", exp.Message); } catch (ArgumentNullException exp) { ModelState.AddModelError("img", exp.Message); } catch (InvalidContentTypeException exp) { ModelState.AddModelError("img", exp.Message); } catch { transaction.Rollback(); ModelState.AddModelError("", "Some error occured. Please try again."); } finally { if (transaction != null) { transaction.Dispose(); } } } FirmViewModel firmViewModel = new FirmViewModel { Id = id, Img = null, Firms = firmEditModel.Firms, Languages = await lawyerDbContext.Languages .AsNoTracking() .ToListAsync() }; return(View(firmViewModel)); }