예제 #1
0
        public ColorViewModel Add(ColorViewModel brandVm)
        {
            var brand = Mapper.Map <ColorViewModel, Color>(brandVm);

            _brandRepository.Add(brand);
            return(brandVm);
        }
예제 #2
0
        public bool SaveEntity(ColorModel colorModel)
        {
            try
            {
                if (colorModel.Id > 0)
                {
                    var color = GetColorById(colorModel.Id).ToColor();
                    color.Id          = colorModel.Id;
                    color.Name        = colorModel.Name;
                    color.Code        = colorModel.Code;
                    color.UpdatedDate = DateTime.Now;
                    _colorRepository.Update(color);

                    return(true);
                }
                else
                {
                    var color = new Color();
                    color.Id          = colorModel.Id;
                    color.Name        = colorModel.Name;
                    color.Code        = colorModel.Code;
                    color.CreatedDate = DateTime.Now;
                    _colorRepository.Add(color);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #3
0
 public Color Add(Color color)
 {
     if (_colorRepository.CheckContains(x => x.Name == color.Name))
     {
         throw new NameDuplicatedException("Tên không được trùng");
     }
     return(_colorRepository.Add(color));
 }
예제 #4
0
        public ColorMutation(IColorRepository colorRepository, ITranslationRepository translationRepository)
        {
            Name = "Mutation";

            Field <ColorType>(
                "create",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ColorType> > {
                Name = "color"
            }
                    ),
                resolve: context =>
            {
                var color = context.GetArgument <Color>("color");
                return(colorRepository.Add(color));
            });
        }
예제 #5
0
 public ActionResult Add(ColorDTO entity)
 {
     try
     {
         Color color = new Color()
         {
             ColorName = entity.ColorName
         };
         colorRepository.Add(color);
         colorRepository.Save();
         return(Json(entity, JsonRequestBehavior.DenyGet));
     }
     catch (Exception e)
     {
         return(Json(false, JsonRequestBehavior.DenyGet));
     }
 }
예제 #6
0
        public Response AddColor(Color color)
        {
            Response response = new Response();

            if (colorRepository.GetAll().Any(t => t.ColorName == color.ColorName))
            {
                response.Success = false;
                response.Message = "ERROR: Color name already exists";
            }
            else
            {
                colorRepository.Add(color);
                response.Success = true;
                response.Message = "Color added";
            }
            return(response);
        }
예제 #7
0
 public async Task Add(Color brand)
 {
     await _brandRepository.Add(brand);
 }
 public void AddColor(Color color)
 {
     _colorRepository.Add(color);
 }
예제 #9
0
 public void Add(Color Color)
 {
     _colorRepository.Add(Color);
 }
예제 #10
0
 public IActionResult Add([FromBody]Color color, [FromRoute] int page = 1, [FromRoute]int pagesize = 10)
 {
     _colorRepo.Add(color);
     _colorRepo.Save();
     return ColorsList(page, pagesize);
 }
예제 #11
0
 public Color Add(Color color)
 {
     return(_colorRepository.Add(color));
 }
예제 #12
0
        public void Create(ColorViewModel colorVm)
        {
            var color = _mapper.Map <ColorViewModel, Color>(colorVm);

            _colorRepository.Add(color);
        }
예제 #13
0
 public void Add(Color color)
 {
     colorRepository.Add(color);
     Save();
 }
예제 #14
0
 public async Task Add(ColorViewModel pageVm)
 {
     var page = new ColorViewModel().Map(pageVm);
     await _colorRepository.Add(page);
 }