Ejemplo n.º 1
0
        public async Task <string> CreateService(string carValueId, CarServiceBinding binding)
        {
            using (var context = GetMainContext())
            {
                var entity = binding.ToEntity(context);
                entity.CarId = context.Cars.GetId(carValueId).Value;

                context.CarServices.Add(entity);
                await context.SaveChangesAsync();

                return(entity.ValueId);
            }
        }
Ejemplo n.º 2
0
        public static CarService ToEntity(this CarServiceBinding b, MainContext context, CarService entity = null)
        {
            if (entity == null)
            {
                entity = new CarService();
            }

            entity.CarServiceTypeId = context.CarServiceTypes.GetId(b.TypeId).Value;
            entity.Date             = b.Date;
            entity.Description      = b.Description;
            entity.ValueId          = IdHelper.Generate();

            return(entity);
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> PostService(string id, [FromBody] CarServiceBinding binding) => Ok(await _carHandler.CreateService(id, binding));