public ViewResult Create() { var model = new TaxIncomePersonViewModel(); model.Name = Helpers.Common.GetSetting("companyName"); return(View(model)); }
public ActionResult Detail(int?Id) { var TaxIncomePerson = TaxIncomePersonRepository.GetTaxIncomePersonById(Id.Value); if (TaxIncomePerson != null && TaxIncomePerson.IsDeleted != true) { var model = new TaxIncomePersonViewModel(); AutoMapper.Mapper.Map(TaxIncomePerson, model); List <int?> arrStaffIds = taxIncomePersonDetailRepository.GetAllTaxIncomePersonDetail().Where(n => n.TaxIncomePersonId == Id.Value).Select(n => n.StaffId).ToList(); List <StaffsTaxModel> modelStaff = staffsRepository.GetvwAllStaffs() .Select(item => new StaffsTaxModel { Id = item.Id, Name = item.Name, Code = item.Code, DistrictName = item.DistrictName, BranchId = item.Sale_BranchId, Email = item.Email, EndDate = item.EndDate, StartDate = item.StartDate, Gender = item.Gender, IdCardNumber = item.IdCardNumber, BranchName = item.BranchName, ContryName = item.CountryId, ProvinceName = item.ProvinceName, WardName = item.WardName }).OrderByDescending(m => m.Id).ToList(); model.ListStaffsTax = modelStaff.Where(n => arrStaffIds.Contains(n.Id)); if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1) { TempData["FailedMessage"] = "NotOwner"; return(RedirectToAction("Index")); } return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ActionResult Edit(TaxIncomePersonViewModel model) { if (ModelState.IsValid) { if (Request["Submit"] == "Save") { var TaxIncomePerson = TaxIncomePersonRepository.GetTaxIncomePersonById(model.Id); var _model = TaxIncomePersonRepository.GetAllTaxIncomePerson().Where(n => n.Code != TaxIncomePerson.Code && n.Code == model.Code); if (_model != null && _model.Count() > 0) { //StaffsTaxModel string staffids = Request["StaffIds"]; if (!string.IsNullOrEmpty(staffids)) { List <string> arrStaffIds = staffids.Split(',').ToList(); List <StaffsTaxModel> modelStaff = staffsRepository.GetvwAllStaffs() .Select(item => new StaffsTaxModel { Id = item.Id, Name = item.Name, Code = item.Code, DistrictName = item.DistrictName, BranchId = item.Sale_BranchId, Email = item.Email, EndDate = item.EndDate, StartDate = item.StartDate, Gender = item.Gender, IdCardNumber = item.IdCardNumber, BranchName = item.BranchName, ContryName = item.CountryId, ProvinceName = item.ProvinceName, WardName = item.WardName }).OrderByDescending(m => m.Id).ToList(); model.ListStaffsTax = modelStaff.Where(n => arrStaffIds.Contains(n.Id.ToString())); ViewBag.FailedMessage = "Mã số thuế đã tồn tại"; } return(View(model)); } AutoMapper.Mapper.Map(model, TaxIncomePerson); TaxIncomePerson.ModifiedUserId = WebSecurity.CurrentUserId; TaxIncomePerson.ModifiedDate = DateTime.Now; TaxIncomePersonRepository.UpdateTaxIncomePerson(TaxIncomePerson); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess; return(RedirectToAction("Index")); } return(View(model)); } return(View(model)); //if (Request.UrlReferrer != null) // return Redirect(Request.UrlReferrer.AbsoluteUri); //return RedirectToAction("Index"); }
public ActionResult Create(TaxIncomePersonViewModel model) { var _model = TaxIncomePersonRepository.GetAllTaxIncomePerson().Where(n => n.Code == model.Code); if (_model != null && _model.Count() > 0) { //StaffsTaxModel string staffids = Request["StaffIds"]; if (!string.IsNullOrEmpty(staffids)) { List <string> arrStaffIds = staffids.Split(',').ToList(); List <StaffsTaxModel> modelStaff = staffsRepository.GetvwAllStaffs() .Select(item => new StaffsTaxModel { Id = item.Id, Name = item.Name, Code = item.Code, DistrictName = item.DistrictName, BranchId = item.Sale_BranchId, Email = item.Email, EndDate = item.EndDate, StartDate = item.StartDate, Gender = item.Gender, IdCardNumber = item.IdCardNumber, BranchName = item.BranchName, ContryName = item.CountryId, ProvinceName = item.ProvinceName, WardName = item.WardName }).OrderByDescending(m => m.Id).ToList(); model.ListStaffsTax = modelStaff.Where(n => arrStaffIds.Contains(n.Id.ToString())); ViewBag.FailedMessage = "Mã số thuế đã tồn tại"; } return(View(model)); } if (ModelState.IsValid) { //Add Taxperson var TaxIncomePerson = new TaxIncomePerson(); AutoMapper.Mapper.Map(model, TaxIncomePerson); TaxIncomePerson.IsDeleted = false; TaxIncomePerson.CreatedUserId = WebSecurity.CurrentUserId; TaxIncomePerson.ModifiedUserId = WebSecurity.CurrentUserId; TaxIncomePerson.AssignedUserId = WebSecurity.CurrentUserId; TaxIncomePerson.CreatedDate = DateTime.Now; TaxIncomePerson.ModifiedDate = DateTime.Now; TaxIncomePersonRepository.InsertTaxIncomePerson(TaxIncomePerson); //Add Staffs to Detail string staffids = Request["StaffIds"]; if (!string.IsNullOrEmpty(staffids)) { string[] arrStaffIds = staffids.Split(','); for (int i = 0; i < arrStaffIds.Count(); i++) { var TaxIncomePersonDetail = new TaxIncomePersonDetail(); TaxIncomePersonDetail.IsDeleted = false; TaxIncomePersonDetail.CreatedUserId = WebSecurity.CurrentUserId; TaxIncomePersonDetail.ModifiedUserId = WebSecurity.CurrentUserId; TaxIncomePersonDetail.AssignedUserId = WebSecurity.CurrentUserId; TaxIncomePersonDetail.CreatedDate = DateTime.Now; TaxIncomePersonDetail.ModifiedDate = DateTime.Now; TaxIncomePersonDetail.StaffId = int.Parse(arrStaffIds[i]); TaxIncomePersonDetail.TaxIncomePersonId = TaxIncomePerson.Id; taxIncomePersonDetailRepository.InsertTaxIncomePersonDetail(TaxIncomePersonDetail); } } TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("Index")); } return(View(model)); }