protected int Add(T entity) { try { _service.Add(entity); return(_uow.SaveChanges()); } catch (Exception ex) { var a = ex; throw; } }
public void Create(CustomerDto model) { var customerEntity = Mapper.Map <Customer>(model); foreach (var relationItem in customerEntity.Insurances) { var relation = new CustomerInsurances { CustomerId = customerEntity.Id, InsuranceId = relationItem.Id }; _insuranceCustomerRepository.Add(relation); } _customerRepository.Add(customerEntity); }
public Result Add(Abonado abonado) { var result = repositorio.Add <Abonado>(abonado); repositorio.SaveChanges(); return(new Result { Object = result }); }
public Result Add(User user) { var result = repositorio.Add <User>(user); repositorio.SaveChanges(); return(new Result { Object = result }); }
public Result Add(Model.Service service) { var result = repositorio.Add <Model.Service>(service); repositorio.SaveChanges(); return(new Result { Object = result }); }
public IActionResult AddCar(CarVm carVm) { if (!ModelState.IsValid) { return(View(carVm)); } Car car = new Car { Model = carVm.Model, Color = carVm.Color, NumberOfDoors = carVm.NumberOfDoors, ProductionDate = carVm.ProductionDate }; _carService.Add(car); return(RedirectToAction("Index")); }
public IActionResult Post([FromBody] ItemViewModel model) { _repositoryService.Add(model); if (!_repositoryService.IsValid) { foreach (var keyValuePair in _repositoryService.Errors) { ModelState.AddModelError(keyValuePair.Key, keyValuePair.Value); } } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _repositoryService.Save(); return(Ok()); }
public async Task <ActionResult <Instructor> > CreateInstructor(Instructor instructor) { try { if (instructor == null) { return(BadRequest()); } var createdInstructor = await repositoryService.Add(instructor); return(CreatedAtAction(nameof(GetInstructor), new { id = createdInstructor.Id }, createdInstructor)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error creating data from the database")); } }
public async Task <ActionResult <DrivingDate> > CreateDrivingDate(DrivingDate drivingDate) { try { if (drivingDate == null) { return(BadRequest()); } var createdDrivingDate = await repositoryService.Add(drivingDate); return(CreatedAtAction(nameof(GetDrivingDate), new { id = drivingDate.Id }, drivingDate)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error creating data from the database")); } }
public async Task<ActionResult<Course>> CreateCategory(Category category) { try { if (category == null) { return BadRequest(); } var createdCategory = await repositoryService.Add(category); return CreatedAtAction(nameof(GetCategory), new { id = createdCategory.Id }, createdCategory); } catch (Exception) { return StatusCode(StatusCodes.Status500InternalServerError, "Error creating data from the database"); } }
public async Task <ActionResult <Course> > CreateCourse(Course course) { try { if (course == null) { return(BadRequest()); } var createdCourse = await repositoryService.Add(course); return(CreatedAtAction(nameof(GetCourse), new { id = createdCourse.Id }, createdCourse)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error creating data from the database")); } }
public void Create(InsuranceDto model) { var customerEntity = Mapper.Map <Domain.Insurance.Insurance>(model); _insuranceRepository.Add(customerEntity); }
public bool Insert([FromBody] Product product) { return(_service.Add(product)); }
public bool Insert([FromBody] Necessity necessity) { return(_service.Add(necessity)); }
public bool Insert([FromBody] Unit unit) { return(_service.Add(unit)); }
public TEntity Add(TEntity model) { return(_repositoryService.Add(model)); }
public bool Insert(Recipe recipe) { return(_service.Add(recipe)); }
public async Task <bool> AddAsync(T entity) { _repositoryService.Add(entity); return(await Repositories.SaveChangesAsync() > 0); }