public ActionResult Create(Product product)
        {
            try
            {
                _storeService.Create(product);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public void Create(StoreModel model)
        {
            //Store entity = new Store()
            //{
            //    Name = model.Name,
            //    Address = model.Address,
            //    Contact = model.Contact,
            //    CreatedBy = model.CreateBy,
            //    CreatedOn = model.CreatedOn,
            //    Phone = model.Phone
            //};
            var entity = model.MapTo <Store>();

            _service.Create(entity);
            _db.SaveChange();
        }
        public ActionResult Post([FromBody] StoreDTO value)
        {
            TryValidateModel(value);

            try
            {
                var store = mapper.Map <Store>(value);
                service.Create(store);
                value.Id = store.Id;
                return(Created(Url.Action("Get", new { Id = value.Id }), value));
            }
            catch
            {
                return(BadRequest(new { Success = false, Message = "The name is already in use" }));
            }
        }
Exemplo n.º 4
0
        public ActionResult Post([FromBody] StoreDTO value)
        {
            TryValidateModel(value);

            try
            {
                var store = mapper.Map <Store>(value);
                service.Create(store);
                value.Id = store.Id;
                return(Ok(new { Success = true, Message = "", data = value }));
            }
            catch (Exception ex)
            {
                logger.LogCritical(ex.StackTrace);
                return(Ok(new { Success = false, Message = "The name is already in use" }));
            }
        }
Exemplo n.º 5
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IStoreRepository>();
            var model = new ApiStoreRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Store>())).Returns(Task.FromResult(new Store()));
            var service = new StoreService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.StoreModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLStoreMapperMock,
                                           mock.DALMapperMockFactory.DALStoreMapperMock,
                                           mock.BOLMapperMockFactory.BOLCustomerMapperMock,
                                           mock.DALMapperMockFactory.DALCustomerMapperMock);

            CreateResponse <ApiStoreResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.StoreModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiStoreRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Store>()));
        }
Exemplo n.º 6
0
        public HttpResponseMessage PostStore(Object content)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Unused);

            try
            {
                String       storeJSON = content.ToString();
                Store        store     = JsonConvert.DeserializeObject <Store>(storeJSON);
                StoreService ss        = new StoreService();
                if (ss.Create(store))
                {
                    response = new HttpResponseMessage(HttpStatusCode.OK);
                }
                else
                {
                    response = new HttpResponseMessage(HttpStatusCode.ExpectationFailed);
                }
            }
            catch
            {
                response = new HttpResponseMessage(HttpStatusCode.Unused);
            }
            return(response);
        }
Exemplo n.º 7
0
 public void Post([FromBody] Items item)
 {
     storeService.Create(item);
 }
Exemplo n.º 8
0
        public ActionResult <Store> Create(Store store)
        {
            _storeService.Create(store);

            return(CreatedAtRoute("GetStore", new { id = store.Id.ToString() }, store));
        }
 public void TestCreate()
 {
     var target = new StoreService();
     Assert.IsTrue(target.Create());
 }