public void Delete(ProviderBindingModel model) { var customer = storage.GetElement( new ProviderBindingModel { Id = model.Id }); if (customer == null) { throw new Exception("поставщик не найден"); } storage.Delete(model); }
public List <ProviderViewModel> Read(ProviderBindingModel model) { if (model == null) { return(storage.GetFullList()); } if (model.Id.HasValue) { return(new List <ProviderViewModel> { storage.GetElement(model) }); } return(null); }
public bool Login(ProviderBindingModel model) { var provider = storage.GetElement( new ProviderBindingModel { Login = model.Login, Mail = model.Mail }); if (provider == null || !provider.Password.Equals(model.Password)) { throw new Exception("поставщик c такими данными не найден"); } return(true); }
public void Delete(ProviderBindingModel model) { using (var context = new MebelDatabase()) { Provider element = context.Providers.FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Providers.Remove(element); context.SaveChanges(); } else { throw new Exception("Поставщик не найден"); } } }
private Provider CreateModel(ProviderBindingModel model, Provider provider, Context context) { User user = new User { FirstName = model.FirstName, LastName = model.LastName, Login = model.Login, Password = model.Password, Mail = model.Mail, }; context.Users.Add(user); context.SaveChanges(); provider.UserId = user.Id; return(provider); }
public ProviderViewModel GetElement(ProviderBindingModel model) { if (model == null) { return(null); } using (var context = new Context()) { var provider = context.Providers .Include(rec => rec.User) .FirstOrDefault(rec => rec.User.Login == model.Login || rec.UserId == model.Id); return(provider != null?CreateViewModel(provider) : null); } }
public void CreateOrUpdate(ProviderBindingModel model) { var customer = _customerStorage.GetElement(new ProviderBindingModel { FullName = model.FullName }); if (customer != null && customer.Id != model.Id) { throw new Exception("Уже есть такой пользователь"); } if (model.Id.HasValue) { _customerStorage.Update(model); } else { _customerStorage.Insert(model); } }
public List <ProviderViewModel> Read(ProviderBindingModel model) { using (var context = new GoToWorkDatabase()) { return(context.Providers .Where( rec => model == null || rec.Id == model.Id || rec.Email == model.Email && rec.Password == model.Password ) .Select(rec => new ProviderViewModel { Id = rec.Id, FIO = rec.FIO, Email = rec.Email, Password = rec.Password }) .ToList()); } }
public async Task <IActionResult> NewProvider([FromBody] ProviderBindingModel providerBindingModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrors())); } var(imageBucket, outcomeAction, error) = await _imageBucketRepository.NewImageBucket( new ImageBucket { StoreBucket = new ImageBucketKey { Store = Constants.PROVIDER_IMAGES_STORE }, ImageList = new List <string>() }); if (outcomeAction != RepositoryOutcomeAction.OkCreated) { return(this.StatusCode(500, error)); } var provider = new Provider { Email = providerBindingModel.Email, Name = providerBindingModel.Name, State = providerBindingModel.State, City = providerBindingModel.City, ZipCode = providerBindingModel.ZipCode, Address = providerBindingModel.Address, ProviderImageBucketKey = imageBucket.StoreBucket, }; (provider, outcomeAction, error) = await _providerRepository.NewAsync(provider); return(this.FromRepositoryOutcome( outcomeAction, error, MapToProviderViewModel(provider), Url.BuildGetProviderUrl(provider?.Id))); }
public void CreateOrUpdate(ProviderBindingModel model) { var provider = storage.GetElement( new ProviderBindingModel { Login = model.Login }); if (provider != null && provider.Id != model.Id) { throw new Exception("Уже есть поставщик с таким логином"); } if (model.Id.HasValue) { storage.Update(model); } else { storage.Insert(model); } }
public async Task <IActionResult> UpdateProvider(string id, [FromBody] ProviderBindingModel providerBindingModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrors())); } var providerPatch = new Provider { Id = id, Email = providerBindingModel.Email, Name = providerBindingModel.Name, State = providerBindingModel.State, City = providerBindingModel.City, ZipCode = providerBindingModel.ZipCode, Address = providerBindingModel.Address, }; var(provider, outcomeAction, error) = await _providerRepository.PatchAllButProviderImageStoreAsync(providerPatch); return(this.FromRepositoryOutcome(outcomeAction, error, MapToProviderViewModel(provider))); }
public List <ProviderViewModel> GetFilteredList(ProviderBindingModel model) { if (model == null) { return(null); } using (var context = new TechiqueShopDatabase()) { return(context.Providers .Where(rec => rec.ProviderName.Contains(model.ProviderName)) .Select(rec => new ProviderViewModel { Id = rec.Id, ProviderName = rec.ProviderName, ProviderSurname = rec.ProviderSurname, Patronymic = rec.Patronymic, Telephone = rec.Telephone, Email = rec.Email, Password = rec.Password, UserType = rec.UserType }) .ToList()); } }
public void Update(ProviderBindingModel model) { throw new NotImplementedException(); }
public List <ProviderViewModel> GetFilteredList(ProviderBindingModel model) { throw new NotImplementedException(); }
public void UpdateData(ProviderBindingModel model) { CheckData(model); _logic.CreateOrUpdate(model); }
public void Registration(ProviderBindingModel model) { CheckData(model); _logic.CreateOrUpdate(model); }
private Provider CreateModel(ProviderBindingModel model, Provider provider) { provider.FullName = model.FullName; provider.Password = model.Password; return(provider); }