Ejemplo n.º 1
0
        public async Task <IActionResult> CreateRetail([FromForm] RetailViewModel model)
        {
            try
            {
                if (_groupRepository.GetGroup(model.GroupId) == null)
                {
                    return(Error((int)HttpStatusCode.BadRequest));
                }
                await _retailRepository.AddRetail(new RetailModel()
                {
                    Name             = model.Name,
                    GroupId          = model.GroupId,
                    CreateDate       = DateTime.Now,
                    ModificationDate = DateTime.Now
                });

                _eventLog.EventPublish("Create: ", $"{model.RetailId} : {model.Name} at {DateTime.Now}");

                return(Ok(model.Name + " Successfully created"));
            }
            catch (Exception ex)
            {
                return(Error((int)HttpStatusCode.BadRequest, ex));
            }
        }
Ejemplo n.º 2
0
        public string Get(string setting)
        {
            if (setting != "createtest")
            {
                return("Unknown");
            }
            _retailRepository.AddRetail(new RetailModel()
            {
                Name             = "Test retail 1",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
                GroupId          = "1"
            });
            _retailRepository.AddRetail(new RetailModel()
            {
                Name             = "Test retail 2",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
                GroupId          = "1"
            });
            _retailRepository.AddRetail(new RetailModel()
            {
                Name             = "Test retail 3",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
                GroupId          = "2"
            });
            _retailRepository.AddRetail(new RetailModel()
            {
                Name             = "Test retail 4",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
                GroupId          = "3"
            });

            _retailRepository.AddRetail(new RetailModel()
            {
                Name             = "Test retail 5",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
                GroupId          = "3"
            });
            _groupRepository.AddGroup(new GroupModel()
            {
                Name             = "Test group 1",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
            });
            _groupRepository.AddGroup(new GroupModel()
            {
                Name             = "Test group 2",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
            });

            _groupRepository.AddGroup(new GroupModel()
            {
                Name             = "Test group 3",
                CreateDate       = DateTime.Now,
                ModificationDate = DateTime.Now,
            });
            return("Done");
        }