예제 #1
0
 protected int Add(T entity)
 {
     try
     {
         _service.Add(entity);
         return(_uow.SaveChanges());
     }
     catch (Exception ex)
     {
         var a = ex;
         throw;
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        public Result Add(Abonado abonado)
        {
            var result = repositorio.Add <Abonado>(abonado);

            repositorio.SaveChanges();
            return(new Result {
                Object = result
            });
        }
예제 #4
0
        public Result Add(User user)
        {
            var result = repositorio.Add <User>(user);

            repositorio.SaveChanges();
            return(new Result {
                Object = result
            });
        }
예제 #5
0
        public Result Add(Model.Service service)
        {
            var result = repositorio.Add <Model.Service>(service);

            repositorio.SaveChanges();
            return(new Result {
                Object = result
            });
        }
예제 #6
0
        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());
        }
예제 #8
0
        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"));
            }
        }
예제 #9
0
        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"));
            }
        }
예제 #10
0
        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");
            }
        }
예제 #11
0
        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"));
            }
        }
예제 #12
0
        public void Create(InsuranceDto model)
        {
            var customerEntity = Mapper.Map <Domain.Insurance.Insurance>(model);

            _insuranceRepository.Add(customerEntity);
        }
예제 #13
0
 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));
 }
예제 #16
0
 public TEntity Add(TEntity model)
 {
     return(_repositoryService.Add(model));
 }
예제 #17
0
 public bool Insert(Recipe recipe)
 {
     return(_service.Add(recipe));
 }
예제 #18
0
 public async Task <bool> AddAsync(T entity)
 {
     _repositoryService.Add(entity);
     return(await Repositories.SaveChangesAsync() > 0);
 }