public async Task <IHttpActionResult> PostNewPhone(PhoneModel phone) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } int idClient = User.Identity.GetUserId <int>(); var client = await Manager.FindUserByIdWithPhoneNumberAsync(idClient); var NewPhoneAdd = new PhoneNumber() { Phone = phone.Phone, PhoneType = phone.Type }; if (phone.IsPrimary) { if (client.PrincipalPhone != null) { ModelState.AddModelError("principal_phone", GenericError.ALREADY_EXISTS); return(BadRequest(ModelState)); } NewPhoneAdd = _repoPhone.Add(NewPhoneAdd); client.PrincipalPhone = NewPhoneAdd; await Manager.UpdateAsync(client); } else { NewPhoneAdd = _repoPhone.Add(NewPhoneAdd); client.SecondaryPhone.Add(NewPhoneAdd); await Manager.UpdateAsync(client); } return(Ok(NewPhoneAdd)); }
public async Task AddPhone(Phone phone) { if (!PerformValidation(new PhoneValidation(), phone)) { return; } await _phoneRepository.Add(phone); }
public async Task Add(Phone phone) { if (!IsValid(phone)) { return; } await _phoneRepository.Add(phone); }
public void Add(Phone phone) { if (phone == null) { throw new ArgumentNullException(nameof(phone)); } repository.Add(phone); }
public async Task <IActionResult> CreateModel(PhoneModel phoneModel) { _repo.Add(phoneModel); await _repo.SaveAll(); return(NoContent()); throw new Exception("Creating the phone model failed on save"); }
public async Task <IActionResult> CreateSale(Sale sale) { _repo.Add(sale); await _repo.SaveAll(); return(NoContent()); throw new Exception("Saving the sales detail failed"); }
public async Task <IActionResult> CreateSupplier(Supplier supplier) { _repo.Add(supplier); await _repo.SaveAll(); return(NoContent()); throw new Exception("Creating the supplier failed on save"); }
public async Task <IActionResult> CreateBrand(PhoneType phoneType) { _repo.Add(phoneType); await _repo.SaveAll(); return(NoContent()); throw new Exception("Creating the phone brand failed on save"); }
public async Task <IActionResult> CreatePhone(Phone phone) { _repo.Add(phone); await _repo.SaveAll(); return(NoContent()); throw new Exception("Saving the phone details failed"); }
public async Task <IActionResult> CreateInventory(Inventory inventory) { _repo.Add(inventory); await _repo.SaveAll(); return(NoContent()); throw new Exception("Saving the shop details failed"); }
public IActionResult Create(Phone phone) { if (ModelState.IsValid) { _phoneRepository.Add(phone); return(RedirectToAction(nameof(Index))); } ViewData["CompanyId"] = new SelectList(_companyRepository.GetAll(), "Id", "Name"); return(View(phone)); }
public IActionResult Post([FromBody] Phone value) { if (value == null) { return(BadRequest()); } var createdPhone = _phoneRepository.Add(value); return(CreatedAtRoute("GetPhone", new { id = createdPhone.Id }, createdPhone)); }
public PhonesRpcController() { repository.Add(new Phone() { Id = "samsung-gem", Age = 30, Name = "Samsung" }); repository.Add(new Phone() { Id = "Nokia-gem", Age = 40, Name = "Nokia" }); repository.Add(new Phone() { Id = "micromax-gem", Age = 10, Name = "Micromax" }); }
private void RegisterPhones(ICollection <PhoneCommand> phones, InstitutionUser institutionUser) { if (phones == null) { return; } foreach (var phone in phones) { _phoneRepository.Add(new Phone(Guid.NewGuid(), institutionUser.Id, phone.Number)); } }
static void Main(string[] args) { Console.WriteLine("Start!"); Shop shop = new Shop("Москва", "Шереметивская", 6); _shopRepository.Add(shop); Phone phone = new Phone(shop.Id, "mi8", "телефон среднего ценового класса", "процессор: Qualcomm Snapdragon 439, 2000МГц, 8-ми ядерный...", 20000); _phoneRepository.Add(phone); }
public IActionResult Create([FromBody] Phone phone) { try { if (phone == null) { return(BadRequest()); } _phoneRepository.Add(phone); return(new ObjectResult(new AppResponse("Phone Created", null, true))); } catch (Exception e) { return(StatusCode(500, new AppResponse("Oops.. An Error Occurred!", e, true))); } }
public IActionResult Add(AddPhoneViewModel model, [FromRoute] int id) { if (ModelState.IsValid) { Phone phone = new Phone { phoneNumber = model.Number, PhoneType = model.Type, phoneId = id }; PhoneRepo.Add(phone); return(RedirectToAction("Detail", "People")); } else { return(View(model)); } }
public IActionResult Add(AddPhoneViewModel model) { if (ModelState.IsValid) { Phone phone = new Phone { PersonId = model.PersonId, PhoneNumber = model.Number, PhoneType = model.Type }; _phoneRepository.Add(phone); return(RedirectToAction("Details", "People", new { id = phone.PersonId })); } else { return(View(model)); } }
public IActionResult Create(PhoneCreateViewModel model) { if (ModelState.IsValid) { string uniqueFileName = ProcessUploadedFile(model); Phone newphone = new Phone { Name = model.Name, Color = model.Color, Type = model.Type, Dimension = model.Dimension, Price = model.Price, PhotoPath = uniqueFileName }; _phoneRepository.Add(newphone); return(RedirectToAction("details", new { id = newphone.Id })); } return(View()); }
public void Add(Phone phone) { _phoneRepository.Add(phone); }