public void Test()
        {
            var brand = new Brand
            {
                Title = "Brand 1"
            };

            var clockType = new ClockType
            {
                Title = "Clock Type 1"
            };

            var payment = new Payment
            {
                Title = "Payment 1"
            };

            var delivery = new Delivery
            {
                Title = "Delivery 1"
            };

            _brandRepository.Add(brand);
            _clockTypeRepository.Add(clockType);
            _paymentRepository.Add(payment);
            _deliveryRepository.Add(delivery);
        }
示例#2
0
        public BrandViewModel Add(BrandViewModel brandVm)
        {
            var brand = Mapper.Map <BrandViewModel, Brand>(brandVm);

            _brandRepository.Add(brand);
            return(brandVm);
        }
示例#3
0
        public void Create(BrandViewModel model)
        {
            var entity = mapper.Map(model, new Brand());

            brandRepository.Add(entity);
            brandRepository.SaveChanges();
        }
示例#4
0
        //Thêm Brand mới vào bảng MES_Audit_Brand
        public async Task <bool> Add(BrandDto model)
        {
            var brand = _mapper.Map <MES_Audit_Brand>(model);

            _repoBrand.Add(brand);
            return(await _repoBrand.SaveAll());
        }
示例#5
0
        public long Add(Brand obj)
        {
            long retId = 0;

            if (obj.ProductId != 0 && obj.ProductId != null)
            {
                var product = _productRepository.GetById(obj.ProductId ?? 0);
                obj.ProductCode = product.ProductCode;
            }
            if (IsDuplicate(obj.Code, obj.Id, obj.CustomerId) == false)
            {
                retId = _brandRepository.Add(obj);
            }
            else
            {
                Expression <Func <Brand, bool> > res;

                res = x => x.Code.ToLower() == obj.Code.ToLower() && x.CustomerId == obj.CustomerId && x.IsActive == false;
                var brand = _brandRepository.Get(res);
                if (brand != null)
                {
                    retId = brand.Id;

                    obj.Id       = retId;
                    obj.IsActive = true;

                    _brandRepository.Detach(brand);

                    _brandRepository.Update(obj);
                    //return obj.Id;
                }
            }

            return(retId);
        }
示例#6
0
        public async Task <ActionResult> Add(BrandDtos brandDtos)
        {
            try
            {
                var exit = await _brandRepository.GetallAsyn();

                foreach (var see in exit)
                {
                    if (see.Name == brandDtos.Name)
                    {
                        return(BadRequest("This brand already exists, Please enter a different one to this one."));
                    }
                }

                var brand = _mapper.Map <Brand>(brandDtos);

                var NewBrand = await _brandRepository.Add(brand);

                if (brand == null)
                {
                    return(BadRequest("Could not create a new Brand."));
                }

                return(Ok("A new brand has been created."));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
示例#7
0
        public Tuple <BrandViewModel, IReadOnlyCollection <Notification> > Add(BrandViewModel viewModel)
        {
            Brand entity = _mapper.Map <Brand>(viewModel);

            if (entity.Valid)
            {
                var brand = _brandRepository.Find(x => x.Name.ToLower() == entity.Name.ToLower()).ToList();
                if (!brand.Any())
                {
                    _brandRepository.Add(entity);
                    CommandResponse commandResponse = _unitOfWork.Commit();
                    if (!commandResponse.Success)
                    {
                        entity.AddNotification("", "Erro ao salvar");
                    }
                }

                else
                {
                    entity.AddNotification("Brand", "Marca ja cadastrada");
                }
            }

            AddNotifications(entity.Notifications);
            return(new Tuple <BrandViewModel, IReadOnlyCollection <Notification> >(_mapper.Map <BrandViewModel>(entity), entity.Notifications));
        }
        public async Task <BrandResponseModel> Create(BrandCreateRequestModel createModel)
        {
            var brand      = _mapper.Map <Brand>(createModel);
            var addedBrand = await _brandRepository.Add(brand);

            return(_mapper.Map <BrandResponseModel>(addedBrand));
        }
示例#9
0
        private BrandItemEntity Create(BrandInfo brandInfo, List <BrandItemEntity> entitiesToInsert = null)
        {
            BrandItemEntity brand = LoadAssembler.Assemble(brandInfo);

            brandRepository.Add(brand);
            entitiesToInsert?.Add(brand);
            return(brand);
        }
        public async Task Add(BrandDTO AddDTO)
        {
            await _brandRepository.Add(_Mapper.Map <Brands>(AddDTO));

            await _brandRepository.Commit();

            await _brandRepository.DisposeAsync();
        }
示例#11
0
        public Brand CreateBrand(BrandViewModel brandViewModel)
        {
            Brand brand = _brandRepository.Add(new Brand()
            {
                Name = brandViewModel.Name,
            });

            return(brand);
        }
示例#12
0
            public async Task <string> Handle(CreateBrandCommand request, CancellationToken cancellationToken)
            {
                var newBrandToAdd = new Brand(request.Name, request.PhotoUrl);

                _brandRepository.Add(newBrandToAdd);

                await _brandRepository.UnitOfWork.SaveEntitiesSeveralTransactionsAsync(cancellationToken);

                return(newBrandToAdd.Id.ToString());
            }
示例#13
0
        protected void gvBrandDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("ADD"))
            {
                TextBox txtAddBrandName   = (TextBox)gvBrandDetails.FooterRow.FindControl("txtAddBrandName");
                TextBox txtAddDescription = (TextBox)gvBrandDetails.FooterRow.FindControl("txtAddDescription");
                ListBox lstCategory       = (ListBox)gvBrandDetails.FooterRow.FindControl("lstCategory");

                if (txtAddBrandName.Text != ("") && txtAddDescription.Text != ("") && lstCategory.Text != (""))
                {
                    Domain.Brand brand = new Domain.Brand()
                    {
                        BrandDescription = txtAddDescription.Text,
                        BrandName        = txtAddBrandName.Text,
                        CreationTime     = DateTime.Now,
                        LastUpdationTime = DateTime.Now,
                        CreatedBy        = "admin",
                        LastUpdatedBy    = "admin",
                        TenantId         = tenantId,
                    };
                    brand.CategoryBrandMappings = new List <CategoryBrandMapping>();
                    foreach (var index in lstCategory.GetSelectedIndices())
                    {
                        brand.CategoryBrandMappings.Add(new CategoryBrandMapping()
                        {
                            Brand = brand, CategoryId = Convert.ToInt32(lstCategory.Items[index].Value), TenantId = tenantId
                        });
                    }


                    brandRepo.Add(brand);
                    brandRepo.Save();
                    BindData();
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Brand Sucessfully Inserted');", true);
                    BindData();
                }

                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Null Filled Not allowed');", true);
                }
            }
            //conn.Open();
            //string cmdstr = "insert into EmployeeDetails(empid,name,designation,city,country) values(@empid,@name,@designation,@city,@country)";
            //SqlCommand cmd = new SqlCommand(cmdstr, conn);
            //cmd.Parameters.AddWithValue("@empid", txtAddEmpID.Text);
            //cmd.Parameters.AddWithValue("@name", txtAddName.Text);
            //cmd.Parameters.AddWithValue("@designation", txtAddDesignation.Text);
            //cmd.Parameters.AddWithValue("@city", txtAddCity.Text);
            //cmd.Parameters.AddWithValue("@country", txtAddCountry.Text);
            //cmd.ExecuteNonQuery();
            //conn.Close();
            //BindData();
        }
示例#14
0
        public ServiceResult AddBrand(Brand brand)
        {
            if (!ValidateBusinessRules(new BrandAddValidations(_brandRepository).Validate(brand)))
            {
                return(FailResult(Errors));
            }

            _brandRepository.Add(brand);

            return(Commit() ? OkResult(brand) : FailResult(Errors));
        }
示例#15
0
        public async Task <long> Handle(CreateBrandCommand request, CancellationToken cancellationToken)
        {
            var brand = new Domain.Entities.Brand()
            {
                Name = request.Name
            };

            await _brandRepository.Add(brand);

            return(brand.Id);
        }
示例#16
0
        public async Task <Queries.BrandViewModel> Handle(CreateBrandCommand request, CancellationToken cancellationToken)
        {
            Domain.AggregatesModel.BrandAggregate.Brand brand = new Domain.AggregatesModel.BrandAggregate.Brand(brandName: request.BrandName, groupKey: request.GroupKey, tentantId: request.TentantId, description: request.Description);
            _brandRepository.Add(brand);
            var result = await _brandRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);

            if (!result)
            {
                return(null);
            }
            return(_mapper.Map <Queries.BrandViewModel>(brand));
        }
        public void CreateBrand(BrandViewModel brandViewModel)
        {
            Brand brand = new Brand()
            {
                BrandID          = brandViewModel.BrandID,
                BrandTitle       = brandViewModel.BrandTitle,
                BrandName        = brandViewModel.BrandName,
                BrandDescription = brandViewModel.BrandDescription,
                BrandImage       = brandViewModel.BrandImage
            };

            BrandRepository.Add(brand);
            UnityOfWork.Commit();
        }
示例#18
0
        public override IActionResult PostEntity([FromBody] BrandModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var brand = _mapper.Map <Brand>(model);

            AddColors(brand, model);

            _brandRepository.Add(brand);
            return(Ok(_mapper.Map <BrandReturnModel>(brand)));
        }
示例#19
0
        public ActionResult Add(BrandDTO entity)
        {
            try
            {
                Brand brand = Mapper.Map <Brand>(entity);

                brandRepository.Add(brand);
                brandRepository.Save();
                return(Json(entity, JsonRequestBehavior.DenyGet));
            }
            catch (Exception e)
            {
                return(Json(false, JsonRequestBehavior.DenyGet));
            }
        }
示例#20
0
        public async Task <IActionResult> Post([FromBody] BrandViewModel brand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var _newBrand = Mapper.Map <BrandViewModel, Brand>(brand);

            _brandRepository.Add(_newBrand);
            await _brandRepository.Commit();

            var _result = Mapper.Map <Brand, BrandViewModel>(_newBrand);
            var json    = JsonConvert.SerializeObject(_result, _serializerSettings);

            return(new OkObjectResult(json));
        }
示例#21
0
        public Brand CreateBrand(Brand brandToCreate)
        {
            var existingBrand = FindBrand(brandToCreate.BrandName, false);

            if (existingBrand != null)
            {
                Log.Debug("Tried to create a brand that already exists: {0} with Id {1}", existingBrand.BrandName, existingBrand.Id);
                throw new ArgumentException("Can't create two brands with the same name");
            }
            brandToCreate.LastUpdated = DateTime.Now;
            SetOwner(brandToCreate, brandToCreate.CompanyId);
            _brandRepository.Add(brandToCreate);
            _brandRepository.Persist();
            Log.Debug("Brand {0} created with Id {1}", brandToCreate.BrandName, brandToCreate.Id);
            return(brandToCreate);
        }
示例#22
0
        public IActionResult Create([FromBody] Brand Brand)
        {
            try
            {
                if (Brand == null || !ModelState.IsValid)
                {
                    return(BadRequest("Invalid State"));
                }

                BrandRepository.Add(Brand);
            }
            catch (Exception)
            {
                return(BadRequest("Error while creating"));
            }
            return(Ok(Brand));
        }
示例#23
0
        public void SaveBrand(DtoBrand brandDto)
        {
            var brand = new Brand
            {
                Id   = brandDto.Id,
                Name = brandDto.Name
            };

            if (brand.Id == 0)
            {
                _brandRepository.Add(brand);
            }
            else
            {
                _brandRepository.Update(brand);
            }
        }
        public async Task <IActionResult> CreateBrand(BrandForCreationDto brandForCreationDto)
        {
            brandForCreationDto.Name = brandForCreationDto.Name.ToLower();
            var brand = new Brand {
                Name = brandForCreationDto.Name
            };

            if (await _repo.BrandExists(brand))
            {
                return(BadRequest(string.Format("There is already a brand with name: {0}", brand.Name.ToLower())));
            }

            _repo.Add(brand);
            await _repo.SaveAll();

            return(Ok(brand));
        }
示例#25
0
        public void InsertBrand(BrandViewModel brand)
        {
            brand.Status = (int)DbConstant.DefaultDataStatus.Active;
            using (var trans = _unitOfWork.BeginTransaction())
            {
                try
                {
                    Brand entity = new Brand();
                    Map(brand, entity);
                    _brandRepository.Add(entity);
                    _unitOfWork.SaveChanges();

                    trans.Commit();
                }
                catch (System.Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
            }
        }
示例#26
0
        public ActionResult Create([Bind(Include = "Id,Name")] CarBrand brand)
        {
            if (ModelState.IsValid)
            {
                var opStatus = new OperationStatus {
                    Status = true, Message = "Brand added"
                };

                try
                {
                    _brandRepository.Add(brand);
                }
                catch (Exception exp)
                {
                    opStatus = OperationStatus.CreateFromExeption("Error adding brand car.", exp);
                }

                TempData["OperationStatus"] = opStatus;
                return(RedirectToAction("Index"));
            }
            return(View(brand));
        }
示例#27
0
        public async Task <IActionResult> Post(Brand brand)
        {
            try
            {
                var response = await _repository.Add(brand);

                if (response != 0)
                {
                    return(Ok("Added successfully"));
                }
                else
                {
                    return(BadRequest("An error ocurred, contact IT Staff"));
                }
            }
            catch (Exception e)
            {
                //Log error
                Log.Error(e.Message);
                Log.Error(e.StackTrace);
                return(BadRequest("An error ocurred, contact IT Staff"));
            }
        }
示例#28
0
 public void Add(Brand brand)
 {
     _brandRepository.Add(brand);
 }
示例#29
0
 public bool Add(Brand entity)
 {
     return(repository.Add(entity));
 }
示例#30
0
        public void CreateBrand(BrandDto brandDto)
        {
            var brand = brandDto.MappingBrand();

            brandRepository.Add(brand);
        }