Example #1
0
        public async Task <IActionResult> EditStore(StoreViewModel viewModel)
        {
            Store store = viewModel.Map();

            Store oldStore = this.organization.Stores.Where(x => x.Name == store.Name).FirstOrDefault();

            if (oldStore == null)
            {
                return(View("Index", this.organization.Map()));
            }

            this.organization.Stores.Remove(oldStore);
            this.organization.Stores.Add(store);

            await this.organizationRepository.Update(this.organization);

            return(View("Index", this.organization.Map()));
        }
Example #2
0
        public async Task <IActionResult> AddStore(StoreViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Store store = viewModel.Map();

            if (this.organization.Stores == null)
            {
                this.organization.Stores = new List <Store>();
            }

            this.organization.Stores.Add(store);
            await this.organizationRepository.Update(this.organization);

            return(View("Index", this.organization.Map()));
        }