public async Task <IActionResult> WorkerPromotion(WorkerPromotionViewModel model) { if (model.Date < DateTime.Now) { ModelState.AddModelError("Date", "Keçmiş tarixlərə bonus əlavə etmək olmaz"); } else { if (ModelState.IsValid) { WorkerPromotion promotion = new WorkerPromotion() { Id = model.Id, WorkerId = model.WorkerId, Reward = model.Reward, Date = model.Date }; await _dbContext.WorkerPromotions.AddAsync(promotion); await _dbContext.SaveChangesAsync(); return(RedirectToAction("WorkerPromotionList")); } } return(View(model)); }
public async Task <IActionResult> AddCurrent(CurrentWPViewModel model) { ViewBag.Companies = _dbContext.Companies; if (ModelState.IsValid) { CurrentWorkPlace current = new CurrentWorkPlace() { Id = model.Id, WorkerId = model.WorkerId, CompanyId = model.CompanyId, DepartmentId = model.DepartmentId, ShopId = model.ShopId, PositionId = model.PositionId, EntryDate = model.EntryDate, ExitDate = model.ExitDate }; await _dbContext.CurrentWorkPlaces.AddAsync(current); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(Current))); } return(View()); }
public async Task <IActionResult> Create(string name) { Company currentCompany = await _dbContext.Companies.Where(x => x.Name == name) .FirstOrDefaultAsync(); if (name == null) { ModelState.AddModelError("Name", "Boş ola bilməz"); } else { if (currentCompany == null) { await _dbContext.Companies.AddAsync(new Company { Name = name }); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } else { ModelState.AddModelError("Name", "Bu ad artıq mövcuddur"); } } return(View()); }
public async Task <IActionResult> AddVacation(VacationViewModel model) { if (model.VacationStarted < DateTime.Now) { ModelState.AddModelError("VacationStarted", "Keçmiş tarixə əlavə etmək olmaz"); } else { if (ModelState.IsValid) { Vacation vacation = new Vacation() { Id = model.Id, WorkerId = model.WorkerId, VacationStarted = model.VacationStarted, VacationEnded = model.VacationEnded }; await _dbContext.Vacations.AddAsync(vacation); await _dbContext.SaveChangesAsync(); return(RedirectToAction("Index")); } } return(View()); }
public async Task <IActionResult> Add(AttendanceViewModel model) { if (model.Date > DateTime.Now) { ModelState.AddModelError("Date", "Gələcək tarixə qeyd aparmaq olmaz"); } else { if (ModelState.IsValid) { Continuity continuity = new Continuity() { Id = model.Id, WorkerId = model.WorkerId, Date = model.Date, Reason = model.Reason, Status = model.Status, ReasonName = model.ReasonName }; await _dbContext.Continuities.AddAsync(continuity); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View()); }
public async Task <IActionResult> Create(PositionViewModel model) { ViewBag.Companies = await _dbContext.Companies.ToListAsync(); if (ModelState.IsValid) { Position position = new Position() { Id = model.Id, Name = model.Name, Salary = model.Salary, CompanyId = model.CompanyId, DepartmentId = model.DepartmentId }; await _dbContext.Positions.AddAsync(position); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } return(View()); }
public async Task <IActionResult> Create(ShopViewModel model) { ViewBag.Companies = _dbContext.Companies; //ViewBag.Departments = await _dbContext.Departments.ToListAsync(); if (ModelState.IsValid) { Shop newShop = new Shop() { Id = model.Id, Name = model.Name, CompanyId = model.CompanyId, DepartmentId = model.DepartmentId }; await _dbContext.Shops.AddAsync(newShop); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } return(View()); }
public async Task <IActionResult> Create(WorkerViewModel model) { if (model.PassportExpirationDate <= DateTime.Now) { ModelState.AddModelError("PassportExpirationDate", "Passportunuzun son istifade tarixi bitmişdir"); } else { if (ModelState.IsValid) { string uniqueFileName = ProcessUploadFile(model); Worker newWorker = new Worker { Id = model.Id, Name = model.Name, Surname = model.Surname, FatherName = model.FatherName, BirthdayDate = model.BirthdayDate, CurrentAdress = model.CurrentAdress, DistrictRegistration = model.DistrictRegistration, PassportNumber = model.PassportNumber.ToUpper(), PassportExpirationDate = model.PassportExpirationDate, EducationType = model.EducationType, MartialStatus = model.MartialStatus, Gender = model.Gender, EmailAddress = model.EmailAddress, PhotoPath = uniqueFileName }; await _dbContext.Workers.AddAsync(newWorker); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } } return(View()); }
public async Task <IActionResult> Create(DepartmentViewModel model) { var companies = await _dbContext.Companies.ToListAsync(); ViewBag.Company = companies; if (ModelState.IsValid) { Department department = new Department() { Id = model.Id, Name = model.Name, CompanyId = model.CompanyId }; await _dbContext.Departments.AddAsync(department); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } return(View()); }