public IHttpActionResult Update(int id, DTO.MaterialMng.Material 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.MaterialMng.Material>(dtoItem, out notification))
            {
                return(Ok(new Library.DTO.ReturnData <DTO.MaterialMng.Material>()
                {
                    Data = dtoItem, Message = notification
                }));
            }

            // continue processing
            BLL.MaterialMng bll = new BLL.MaterialMng();
            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.MaterialMng.Material>()
            {
                Data = dtoItem, Message = notification
            }));
        }
示例#2
0
 public void DTO2BD_Material(DTO.MaterialMng.Material dtoItem, ref Material dbItem)
 {
     AutoMapper.Mapper.Map <DTO.MaterialMng.Material, Material>(dtoItem, dbItem);
 }