コード例 #1
0
ファイル: FishController.cs プロジェクト: Dakuan/RiftData
        public JsonResult Create(FishEditFormViewModel viewModel)
        {
            this.TryUpdateModel(viewModel);

            var result = this.fishService.CreateFish(viewModel);

            if (result.Success)
            {
                // post a twitter update
                this.twitterService.PostFishAddition(this.fishService.Fish, this.BuildAbsoulteUrl(this.fishService.Fish));

                // log
                this.logger.LogAdd(this.fishService.Fish, this.User.Identity.Name);
            }

            return new JsonResult {Data = result};
        }
コード例 #2
0
ファイル: FishService.cs プロジェクト: Dakuan/RiftData
        public CrudResult UpdateFish(FishEditFormViewModel viewModel)
        {
            try
            {
                this.Fish = this.fishRepository.Update(viewModel.Id, viewModel.Genus, viewModel.Species,
                                                       viewModel.Locales, viewModel.Description);
            }
            catch(ItemDoesNotExistException)
            {
                return new CrudResult {Message = "Item does not exist", Success = false};
            }
            catch (Exception)
            {
                return new CrudResult {Success = false, Message = "An error occured"};
            }

            return new CrudResult {Success = true, Message = string.Format("{0} has been updated", Fish.Name)};
        }
コード例 #3
0
ファイル: FishService.cs プロジェクト: Dakuan/RiftData
        public CrudResult CreateFish(FishEditFormViewModel viewModel)
        {
            try
            {
                this.Fish = this.fishRepository.Add(viewModel.Genus, viewModel.Species, viewModel.Locales,
                                                   viewModel.Description);
            }
            catch (ItemExistsException)
            {
                return new CrudResult {Success = false, Message = "Fish already exists in database"};
            }
            catch(Exception)
            {
                return new CrudResult { Success = false, Message = "An error occured" };
            }

            return new CrudResult
                       {
                           Success = true,
                           Message = string.Format("{0} added to database", Fish.Name)
                       };
        }
コード例 #4
0
ファイル: FishController.cs プロジェクト: Dakuan/RiftData
        public JsonResult Update(FishEditFormViewModel vm)
        {
            this.TryUpdateModel(vm);

            var result = this.fishService.UpdateFish(vm);

            if(result.Success)
            {
                this.logger.LogUpdate(this.fishService.Fish, this.User.Identity.Name);

                this.twitterService.PostFishUpdate(this.fishService.Fish, this.BuildAbsoulteUrl(this.fishService.Fish));
            }

            return new JsonResult {Data = result};
        }