public async Task <IActionResult> PutVendorRegistration(int id, VendorRegistration vendorRegistration) { if (id != vendorRegistration.ID) { return(BadRequest()); } _context.Entry(vendorRegistration).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VendorRegistrationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Get Action for Create /// </summary> /// <returns></returns> public ActionResult Create() { VendorRegistration vendorRegister = new VendorRegistration(); var ven = from v in unitOfWork.VendorRepository.Get() select v; //vendorRegister.DomainItems = ExtensionClass.GetDomains(); vendorRegister.DomainLists = ExtensionClass.GetDomains(); vendorRegister.CountryItems = ExtensionClass.GetCountries(); vendorRegister.StateItems = ExtensionClass.GetStates(); vendorRegister.CityItems = ExtensionClass.GetCities(); vendorRegister.AcademicsItems = ExtensionClass.GetAcademics(); List <VendorLanguagePair> LanguagePairList = new List <VendorLanguagePair> { ExtensionClass.GetLanguagePair() }; vendorRegister.VendorLanguagePair = LanguagePairList; List <VendorSoftware> SoftwareList = new List <VendorSoftware> { ExtensionClass.GetSoftware() }; vendorRegister.VendorSoftware = SoftwareList; List <VendorService> ServicesList = new List <VendorService> { ExtensionClass.GetServices() }; vendorRegister.VendorService = ServicesList; return(View(vendorRegister)); }
[HttpPost("VendorRegister")] // api/Accounts/VendorRegister public async Task <ActionResult> VendorRegister(VendorRegistration userModel) { var user = _mapper.Map <User>(userModel); var vendor = _mapper.Map <Vendor>(userModel); var result = await _userManager.CreateAsync(user, userModel.Password); if (!result.Succeeded) { return(Ok(result.Errors)); } await _userManager.AddToRoleAsync(user, "Vendor"); db.Vendors.Add(vendor); db.SaveChanges(); return(StatusCode(201)); }
public async Task <ActionResult <VendorRegistration> > PostVendorRegistration(VendorRegistration vendorRegistration) { _context.VendorTable.Add(vendorRegistration); await _context.SaveChangesAsync(); return(CreatedAtAction("GetVendorRegistration", new { id = vendorRegistration.ID }, vendorRegistration)); }
public ActionResult Create(VendorRegistration vendorRegister) { try { if (ModelState.IsValid) { } else { bool hasErrors = ViewData.ModelState.Values.Any(x => x.Errors.Count > 1); var errors = ModelState.SelectMany(x => x.Value.Errors.Select(z => z.Exception)); } //create mapping Mapper.CreateMap <VendorRegistration, TBL_Vendor>() .ForMember(v => v.TBL_M_Academics, option => option.Ignore()) .ForMember(v => v.TBL_M_City, option => option.Ignore()) .ForMember(v => v.TBL_M_Country, option => option.Ignore()) .ForMember(v => v.TBL_M_State, option => option.Ignore()) .ForMember(v => v.TBL_TrackerPC, option => option.Ignore()) .ForMember(v => v.TBL_TrackerSPC, option => option.Ignore()) .ForMember(v => v.TBL_VendorLanguagePair, option => option.Ignore()) .ForMember(v => v.TBL_VendorService, option => option.Ignore()) .ForMember(v => v.TBL_VendorDomain, option => option.Ignore()) .ForMember(v => v.TBL_VendorSoftware, option => option.Ignore()) ; Mapper.CreateMap <VendorService, TBL_VendorService>() .ForMember(v => v.TBL_M_Currency, option => option.Ignore()) .ForMember(v => v.TBL_M_Currency1, option => option.Ignore()) .ForMember(v => v.TBL_M_Services, option => option.Ignore()) .ForMember(v => v.TBL_Vendor, option => option.Ignore()) ; Mapper.CreateMap <VendorSoftware, TBL_VendorSoftware>() .ForMember(v => v.TBL_M_Expertise, option => option.Ignore()) .ForMember(v => v.TBL_M_Software, option => option.Ignore()) .ForMember(v => v.TBL_Vendor, option => option.Ignore()) ; Mapper.CreateMap <cDomain, TBL_VendorDomain>() .ForMember(v => v.TBL_M_Domain, option => option.Ignore()) .ForMember(v => v.TBL_Vendor, option => option.Ignore()) ; Mapper.CreateMap <VendorLanguagePair, TBL_VendorLanguagePair>() .ForMember(v => v.TBL_M_Language, option => option.Ignore()) .ForMember(v => v.TBL_M_Language1, option => option.Ignore()) .ForMember(v => v.TBL_Vendor, option => option.Ignore()) ; TBL_Vendor tbl_Vendor = Mapper.Map <VendorRegistration, TBL_Vendor>(vendorRegister); unitOfWork.VendorRepository.Insert(tbl_Vendor); unitOfWork.Save(); foreach (var languagePair in vendorRegister.VendorLanguagePair) { TBL_VendorLanguagePair tbl_VendorLanguagePair = Mapper.Map <VendorLanguagePair, TBL_VendorLanguagePair>(languagePair); tbl_VendorLanguagePair.VendorID = tbl_Vendor.VendorID; tbl_VendorLanguagePair.Status = true; unitOfWork.VendorLanguagePair.Insert(tbl_VendorLanguagePair); } //unitOfWork.Save(); foreach (var service in vendorRegister.VendorService) { TBL_VendorService tbl_VendorService = Mapper.Map <VendorService, TBL_VendorService>(service); tbl_VendorService.VendorID = tbl_Vendor.VendorID; tbl_VendorService.Status = true; unitOfWork.VendorService.Insert(tbl_VendorService); } foreach (var Software in vendorRegister.VendorSoftware) { TBL_VendorSoftware tbl_VendorSoftware = Mapper.Map <VendorSoftware, TBL_VendorSoftware>(Software); tbl_VendorSoftware.VendorID = tbl_Vendor.VendorID; tbl_VendorSoftware.Status = true; unitOfWork.VendorSoftware.Insert(tbl_VendorSoftware); } foreach (var domain in vendorRegister.DomainLists) { if (domain.Selected) { TBL_VendorDomain tbl_VendorDomain = Mapper.Map <cDomain, TBL_VendorDomain>(domain); tbl_VendorDomain.VendorID = tbl_Vendor.VendorID; tbl_VendorDomain.Status = true; unitOfWork.VendorDomain.Insert(tbl_VendorDomain); } } unitOfWork.Save(); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Index")); //return View(); } }