Пример #1
0
        public IHttpActionResult Get(int id)
        {
            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanRead))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            BLL.DeliveryTermMng              bll = new BLL.DeliveryTermMng();
            Library.DTO.Notification         notification;
            DTO.DeliveryTermMng.DeliveryTerm deliveryTerms = bll.GetData(id, ControllerContext.GetAuthUserId(), out notification);
            if (notification.Type == Library.DTO.NotificationType.Error)
            {
                return(InternalServerError(new Exception(notification.Message)));
            }
            return(Ok(new Library.DTO.ReturnData <DTO.DeliveryTermMng.DeliveryTerm>()
            {
                Data = deliveryTerms, Message = notification
            }));
        }
Пример #2
0
        public IHttpActionResult Update(int id, DTO.DeliveryTermMng.DeliveryTerm 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.DeliveryTermMng.DeliveryTerm>(dtoItem, out notification))
            {
                return(Ok(new Library.DTO.ReturnData <DTO.DeliveryTermMng.DeliveryTerm>()
                {
                    Data = dtoItem, Message = notification
                }));
            }

            // continue processing
            BLL.DeliveryTermMng bll = new BLL.DeliveryTermMng();
            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.DeliveryTermMng.DeliveryTerm>()
            {
                Data = dtoItem, Message = notification
            }));
        }
Пример #3
0
 public void DTO2BD_Material(DTO.DeliveryTermMng.DeliveryTerm dtoItem, ref DeliveryTerm dbItem)
 {
     AutoMapper.Mapper.Map <DTO.DeliveryTermMng.DeliveryTerm, DeliveryTerm>(dtoItem, dbItem);
 }