コード例 #1
0
        public async Task <ActionResult <GroupZoneResponse> > PutGroupZone(int id, [FromBody] PutGroupZoneRequest model)
        {
            int brandId = Convert.ToInt32(User.FindFirst("BrandId")?.Value);
            var rs      = await _groupZoneServices.PutGroupZone(id, model, brandId);

            return(Ok(rs));
        }
コード例 #2
0
        public async Task <GroupZoneResponse> PutGroupZone(int id, PutGroupZoneRequest model, int brandId)
        {
            var result = await _unitOfWork.Repository <GroupZone>().GetAll().Where(x => x.Id == id && x.BrandId == brandId).SingleOrDefaultAsync();

            if (result != null)
            {
                result.Name = model.Name;
                await _unitOfWork.Repository <GroupZone>().Update(result, result.Id);

                await _unitOfWork.CommitAsync();

                GroupZoneResponse groupZone = new GroupZoneResponse()
                {
                    Id      = result.Id,
                    BrandId = result.BrandId,
                    Geom    = result.Geom,
                    Name    = result.Name
                };
                return(groupZone);
            }
            return(null);
        }