コード例 #1
0
        /// <summary>
        /// Updates a room.
        /// </summary>
        /// <param name="itemToSave">The item to save.</param>
        /// <param name="accountId">The account identifier.</param>
        /// <returns>The result.</returns>
        public ResultDto UpdateRoom(RoomEditDto itemToSave, Guid?accountId)
        {
            ResultDto result = new ResultDto();

            using (BzsEntityContainer ctx = this.CreateContainer())
            {
                RoomEntity entity = ctx.RoomSet.FirstOrDefault(f => f.Id == itemToSave.Id);
                if (entity == null)
                {
                    result.Error = "ERR-ROOM-NOT-EXISTS";
                    return(result);
                }

                if (entity.AccountId == null || entity.AccountId != accountId)
                {
                    result.Error = "ERR-ROOM-ACCOUNT-INVALID";
                    return(result);
                }

                entity.Code    = itemToSave.Code.Length > 10 ? itemToSave.Code.Substring(0, 9) : itemToSave.Code;
                entity.Caption = itemToSave.Caption.Length > 50 ? itemToSave.Caption.Substring(0, 49) : itemToSave.Caption;
                entity.ModDate = DateTime.Now;
                entity.ModUser = Environment.UserName;

                ctx.SaveChanges();
                result.Success = true;
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Updates a room.
        /// </summary>
        /// <param name="itemToSave">The item to save.</param>
        /// <returns>The result.</returns>
        public ResultDto UpdateRoom(RoomEditDto itemToSave)
        {
            this.SetResponseHeaderCacheExpiration();

            AccountPassword      credentials    = this.GetCredentialsFromRequest();
            AccountServerService accountService = new AccountServerService();
            Guid accountId = accountService.GetAccountId(credentials.Account);

            RoomServerService service = new RoomServerService();

            return(service.UpdateRoom(itemToSave, accountId));
        }