コード例 #1
0
        public IHttpActionResult Update(int id, DTO.CushionMng.Cushion dtoItem)
        {
            Library.DTO.Notification notification;

            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (id > 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanUpdate))
            {
                // edit case
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }
            else if (id == 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanCreate))
            {
                // create new case
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            // validation
            if (!Helper.CommonHelper.ValidateDTO <DTO.CushionMng.Cushion>(dtoItem, out notification))
            {
                return(Ok(new Library.DTO.ReturnData <DTO.CushionMng.Cushion>()
                {
                    Data = dtoItem, Message = notification
                }));
            }

            // continue processing
            BLL.CushionMng bll = new BLL.CushionMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            bll.UpdateData(id, ref dtoItem, ControllerContext.GetAuthUserId(), out notification);
            if (notification.Type == Library.DTO.NotificationType.Error)
            {
                return(InternalServerError(new Exception(notification.Message)));
            }
            return(Ok(new Library.DTO.ReturnData <DTO.CushionMng.Cushion>()
            {
                Data = dtoItem, Message = notification
            }));
        }
コード例 #2
0
 public void DTO2BD(DTO.CushionMng.Cushion dtoItem, ref Cushion dbItem)
 {
     AutoMapper.Mapper.Map <DTO.CushionMng.Cushion, Cushion>(dtoItem, dbItem);
     dbItem.UpdatedDate = DateTime.Now;
 }