public async Task <IActionResult> Create([Bind("Id,Status,Enable")] ContractStatus contractStatus) { if (ModelState.IsValid) { _context.Add(contractStatus); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(contractStatus)); }
public async Task <IActionResult> Create([Bind("Id,FirtsName,LastName,NationalId,Birthday,Gender")] Affiliates affiliates) { if (ModelState.IsValid) { _context.Add(affiliates); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(affiliates)); }
public async Task <IActionResult> Create([Bind("Id,Code,ServiceName,Description")] Services services) { if (ModelState.IsValid) { _context.Add(services); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(services)); }
public async Task <IActionResult> Create([Bind("Id,AffiliateContractId,ServiceId,Observation")] AffiliateContractServices affiliateContractServices) { if (ModelState.IsValid) { //affiliateContractServices.AffiliateContract = _context.AffiliateContracts.Where(x => x.Id == affiliateContractServices.AffiliateContractId).First(); affiliateContractServices.Id = 0; _context.Add(affiliateContractServices); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { id = affiliateContractServices.AffiliateContractId })); } ViewData["AffiliateContractId"] = new SelectList(_context.AffiliateContracts, "Id", "Id", affiliateContractServices.AffiliateContractId); ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Code", affiliateContractServices.ServiceId); return(View(affiliateContractServices)); }
public async Task <IActionResult> Create([Bind("Id,AffiliateId,ContractStatuId,ApplicationDate")] AffiliateContracts affiliateContracts) { var validReg = _context.AffiliateContracts.Where(x => x.AffiliateId == affiliateContracts.AffiliateId && x.ContractStatuId == 4).Count() == 0 ? true: false; if (ModelState.IsValid && validReg) { affiliateContracts.ContractStatuId = 4; affiliateContracts.ApplicationDate = DateTime.Now; _context.Add(affiliateContracts); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), "AffiliateContractServices", new { id = affiliateContracts.Id })); } else { ModelState.AddModelError("AffiliateId", "Can't create new request to contracts by has one pendenting to approve"); } ViewData["AffiliateId"] = new SelectList(_context.Affiliates, "Id", "FirtsName", affiliateContracts.AffiliateId); ViewData["ContractStatuId"] = new SelectList(_context.ContractStatus, "Id", "Status", affiliateContracts.ContractStatuId); return(View(affiliateContracts)); }