public void Put(int id, [FromBody] CreateProviderViewModel provider) { var providerEntity = _mapper.Map <Provider>(provider); providerEntity.Id = id; _providerService.UpdateProvider(providerEntity); }
public ActionResult CreateProviderPost(CreateProviderViewModel viewModel) { if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage open authentication settings"))) { return(new HttpUnauthorizedResult()); } if (!_providerConfigurationService.VerifyUnicity(viewModel.ProviderName)) { ModelState.AddModelError("ProviderName", T("Provider name already exists").ToString()); } if (!ModelState.IsValid) { _orchardServices.TransactionManager.Cancel(); return(View(viewModel)); } _providerConfigurationService.Create(new ProviderConfigurationCreateParams { DisplayName = viewModel.DisplayName, ProviderName = viewModel.ProviderName, ProviderIdentifier = viewModel.ProviderIdentifier, ProviderIdKey = viewModel.ProviderIdKey, ProviderSecret = viewModel.ProviderSecret, }); _orchardServices.Notifier.Information(T("Your configuration has been saved.")); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([FromBody] CreateProviderViewModel model) { string strRuta = _config["ProviderAvatar"]; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Provider modelo = new Provider { CompanyId = model.CompanyId, Enabled = true, Address = model.Address, CountryId = model.CountryId, StateId = model.StateId, CityId = model.CityId, WebSite = model.WebSite, RazonSocial = model.RazonSocial, Phone = model.Phone, DateInitial = DateTime.Now, Documento = model.Documento, DocumentTypeId = model.DocumentTypeId, Email = model.Email, Favorite = model.Favorite, Observation = model.Observation }; _context.Providers.Add(modelo); try { await _context.SaveChangesAsync(); //Guardo el avatar if (modelo.Id > 0) { if (!(string.IsNullOrEmpty(model.LogoName)) && (!string.IsNullOrEmpty(model.Logo))) { strRuta = strRuta + "//" + modelo.Id.ToString() + "//" + model.LogoName; System.IO.FileInfo file = new System.IO.FileInfo(strRuta); file.Directory.Create(); System.IO.File.WriteAllBytes(strRuta, Convert.FromBase64String(model.Logo.Substring(model.Logo.LastIndexOf(',') + 1))); modelo.Logo = strRuta; } } _context.Entry(modelo).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public ActionResult Delete(CreateProviderViewModel model) { var delProvider = providerRepo.ResultTable.Where(i => i.Id == model.ProviderId).First(); var delAddress = addressRepo.ResultTable.Where(i => i.Id == delProvider.AddressId).First(); providerRepo.Delete(delProvider); addressRepo.Delete(delAddress); return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage open authentication settings"))) { return(new HttpUnauthorizedResult()); } CreateProviderViewModel pv = _providerConfigurationService.Get(id); pv.ProviderNameList = getAllProviderName(pv.ProviderName); return(View((Object)pv)); }
public ActionResult CreateProvider() { if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage open authentication settings"))) { return(new HttpUnauthorizedResult()); } CreateProviderViewModel pv = new CreateProviderViewModel(); pv.ProviderNameList = getAllProviderName(); return(View(pv)); }
public ActionResult Edit(CreateProviderViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var provider = _providerMapper .MapToProviderModel(model, _userService.FindByUserName(User.Identity.GetUserName())); _providerService.Update(provider); return(RedirectToAction("Show", new { id = provider.Id })); }
public void Edit(CreateProviderViewModel parameters) { var rec = _repositorystatic.FirstOrDefault(o => o.Id == parameters.Id); rec.DisplayName = parameters.DisplayName; rec.IsEnabled = parameters.IsEnabled ? 1 : 0; rec.ProviderIdentifier = parameters.ProviderIdentifier; rec.UserIdentifier = parameters.UserIdentifier; rec.ProviderIdKey = parameters.ProviderIdKey; rec.ProviderName = parameters.ProviderName; rec.ProviderSecret = parameters.ProviderSecret; _repository.Update(rec); syncRepositoryStatic(); }
public ActionResult Create(CreateProviderViewModel model) { if (!ModelState.IsValid) { model.Categories = _providerMapper.GetCreateProviderViewModel().Categories; return(View(model)); } var creator = _userService.FindByUserName(User.Identity.GetUserName()); var provider = _providerMapper.MapToProviderModel(model, creator); _providerService.Create(provider); return(RedirectToAction("Show", new { id = _providerService.GetAll().Last().Id })); }
public CreateProviderViewModel Get(Int32 id) { var cpvm = new CreateProviderViewModel(); var prec = _repositorystatic.FirstOrDefault(o => o.Id == id); cpvm.Id = prec.Id; cpvm.DisplayName = prec.DisplayName; cpvm.IsEnabled = prec.IsEnabled == 1; cpvm.ProviderIdentifier = prec.ProviderIdentifier; cpvm.UserIdentifier = prec.UserIdentifier; cpvm.ProviderIdKey = prec.ProviderIdKey; cpvm.ProviderName = prec.ProviderName; cpvm.ProviderSecret = prec.ProviderSecret; return(cpvm); }
public Provider MapToProviderModel(CreateProviderViewModel createViewModel, User creator) { return(new Provider { Id = createViewModel.Id, Title = createViewModel.Title, Body = createViewModel.Body, Creator = creator, Price = createViewModel.Price, Category = _providerService.GetCategory(createViewModel.CategoryId), Images = createViewModel.Images?.Trim().Split(' ').Select(image => new Image { Url = image }).ToList() }); }
// GET: ServiceProvider/Create public ActionResult Create() { var locations = locationRepo.ResultTable.ToList(); var locationSelectList = GetLocationList(locations); var users = userRepo.ResultTable.ToList(); var userSelectList = GetUserList(users); var model = new CreateProviderViewModel(); model.Locations = new MultiSelectList(locationSelectList.OrderBy(x => x.Text) , "Value", "Text", model.SelectedLocations); model.ProviderRep = new SelectList(userSelectList.OrderBy(x => x.Text) , "Value", "Text", model.UserId); return(View(model)); }
public CreateProviderViewModel Get(Int32 id) { var cpvm = new CreateProviderViewModel(); var prec = GetProviders().FirstOrDefault(o => o.Id == id); cpvm.Id = prec.Id; cpvm.DisplayName = prec.DisplayName; cpvm.IsEnabled = prec.IsEnabled == 1; cpvm.ProviderIdentifier = prec.ProviderIdentifier; cpvm.UserIdentifier = prec.UserIdentifier; cpvm.ProviderIdKey = prec.ProviderIdKey; cpvm.ProviderName = prec.ProviderName; cpvm.ProviderSecret = prec.ProviderSecret; cpvm.Attributes = prec.Attributes; return(cpvm); }
public ActionResult Create(CreateProviderViewModel provider) { if (ModelState.IsValid) { var P = new CSales.Database.Models.Provider { Contact = provider.Contact, IsActive = provider.IsActive, Name = provider.Name, IsForeignProvider = provider.IsForeignProvider, }; this.db.Database.ExecuteSqlCommand(@"INSERT INTO PROVIDER(NAME, ISACTIVE, CONTACT, ISFOREIGNPROVIDER, BUSINESSNAME, CREATEDDATE) values ({0},{1},{2},{3},{4},{5})", provider.Name, provider.IsActive, provider.Contact, provider.IsForeignProvider, provider.IdBusinessName, DateTime.Now); var newProv = this.db.Provider.OrderByDescending(x => x.Id).FirstOrDefault(); for (int i = 0; i < provider.Addresses.Count(); i++) { this.db.Database.ExecuteSqlCommand(@"INSERT INTO APRV(ADDRESSNAME,DESCRIPTION,IDPRV) values ({0},{1},{2})", provider.Addresses.ElementAt(i), "Descripcion default", newProv.Id); } for (int i = 0; i < provider.Telephones.Count(); i++) { this.db.Database.ExecuteSqlCommand(@"INSERT INTO TELPROV(NUMBER,DESCRIPTION,IDPRV) values ({0},{1},{2})", provider.Telephones.ElementAt(i), "Descripcion default", newProv.Id); } var cCorriente = new CurrentAccountProvider { CreatedDate = DateTime.Now, IdProvider = newProv.Id, TotalDebt = 0 }; this.db.CurrentAcountProvider.Add(cCorriente); this.db.SaveChanges(); return(RedirectToAction("Index")); } this.ViewBag.IdBusinessName = new SelectList(db.BusinessName, "Id", "Name", provider.IdBusinessName); return(View(provider)); }
public ActionResult Edit(CreateProviderViewModel viewModel) { if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage open authentication settings"))) { return(new HttpUnauthorizedResult()); } if (!_providerConfigurationService.VerifyUnicity(viewModel.ProviderName, viewModel.Id)) { ModelState.AddModelError("ProviderName", T("Provider name already exists").ToString()); viewModel.ProviderNameList = getAllProviderName(viewModel.ProviderName); return(View(viewModel)); } else { _providerConfigurationService.Edit(viewModel); _providerConfigurationService.SaveAttributes(viewModel.Id, viewModel.Attributes); return(RedirectToAction("Index")); } }
public void Post([FromBody] CreateProviderViewModel provider) { var providerEntity = _mapper.Map <Provider>(provider); _providerService.AddProvider(providerEntity); }