Beispiel #1
0
 public void DTO2BD(DTO.SubMaterialOptionMng.SubMaterialOption dtoItem, ref SubMaterialOption dbItem)
 {
     AutoMapper.Mapper.Map <DTO.SubMaterialOptionMng.SubMaterialOption, SubMaterialOption>(dtoItem, dbItem);
     dbItem.UpdatedDate = DateTime.Now;
     if (dtoItem.SubMaterialOptionID == 0)
     {
         dbItem.CreatedBy   = dtoItem.CreatedBy;
         dbItem.CreatedDate = DateTime.Now;
     }
 }
        public IHttpActionResult Update(int id, DTO.SubMaterialOptionMng.SubMaterialOption 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.SubMaterialOptionMng.SubMaterialOption>(dtoItem, out notification))
            {
                return(Ok(new Library.DTO.ReturnData <DTO.SubMaterialOptionMng.SubMaterialOption>()
                {
                    Data = dtoItem, Message = notification
                }));
            }

            // continue processing
            BLL.SubMaterialOptionMng bll = new BLL.SubMaterialOptionMng(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.SubMaterialOptionMng.SubMaterialOption>()
            {
                Data = dtoItem, Message = notification
            }));
        }
Beispiel #3
0
 public DTO.SubMaterialOptionMng.SubMaterialOption DB2DTO_SubMaterialOption(SubMaterialOptionMng_SubMaterialOption_View dbItem)
 {
     DTO.SubMaterialOptionMng.SubMaterialOption dtoItem = AutoMapper.Mapper.Map <SubMaterialOptionMng_SubMaterialOption_View, DTO.SubMaterialOptionMng.SubMaterialOption>(dbItem);
     dtoItem.ConcurrencyFlag_String = Convert.ToBase64String(dtoItem.ConcurrencyFlag);
     return(dtoItem);
 }