コード例 #1
0
ファイル: FeatsController.cs プロジェクト: ArmPamKtu/HeroAPI
        public ActionResult Update([FromBody] FeatDto featDto)
        {
            featDto.Created = DateTime.Now;
            bool update = _featLogic.Update(featDto.Id, featDto);

            if (update == true)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #2
0
ファイル: FeatLogic.cs プロジェクト: ArmPamKtu/HeroAPI
        public override FeatDto Create(FeatDto entity)
        {
            using (var scope = Repository.DatabaseFacade.BeginTransaction())
            {
                if (entity.FromUser.Equals(entity.ToUser))
                {
                    throw new BusinessException(ExceptionCode.SendingFeatsToYourself);
                }


                var item = Mapper.Map <Feat>(entity);
                Repository.Create(item);
                Repository.SaveChanges();
                scope.Commit();
            }

            return(entity);
        }
コード例 #3
0
ファイル: FeatLogic.cs プロジェクト: ArmPamKtu/HeroAPI
        public bool Update(Guid entityId, FeatDto entity)
        {
            var success = false;

            if (entity != null)
            {
                using (var scope = Repository.DatabaseFacade.BeginTransaction())
                {
                    var product = Repository.GetByID(entityId);
                    if (product != null)
                    {
                        var item = Mapper.Map(entity, product);
                        Repository.Update(item);
                        Repository.SaveChanges();
                        scope.Commit();
                        success = true;
                    }
                }
            }

            return(success);
        }
コード例 #4
0
ファイル: FeatsController.cs プロジェクト: ArmPamKtu/HeroAPI
 async public Task <ActionResult> Post([FromBody] FeatDto featDto)
 {
     featDto.Created = DateTime.Now;
     _featLogic.Create(featDto);
     return(Ok());
 }