public IHttpActionResult Update(int id, DTO.ShippingInstructionMng.ShippingInstruction 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.ShippingInstructionMng.ShippingInstruction>(dtoItem, out notification))
            {
                return(InternalServerError(new Exception(notification.Message)));
            }

            // continue processing
            BLL.ShippingInstructionMng bll = new BLL.ShippingInstructionMng();
            bll.UpdateData(id, ref dtoItem, ControllerContext.GetAuthUserId(), out notification);
            return(Ok(new Library.DTO.ReturnData <DTO.ShippingInstructionMng.ShippingInstruction>()
            {
                Data = dtoItem, Message = notification
            }));
        }
        public IHttpActionResult GetDefault(int clientId)
        {
            // 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.ShippingInstructionMng bll = new BLL.ShippingInstructionMng();
            Library.DTO.Notification   notification;
            DTO.ShippingInstructionMng.ShippingInstruction data = bll.GetDefault(clientId, out notification);
            return(Ok(new Library.DTO.ReturnData <DTO.ShippingInstructionMng.ShippingInstruction>()
            {
                Data = data, Message = notification, TotalRows = 0
            }));
        }
Esempio n. 3
0
 public void DTO2DB(DTO.ShippingInstructionMng.ShippingInstruction dtoItem, ref ShippingInstruction dbItem)
 {
     // map fields
     AutoMapper.Mapper.Map <DTO.ShippingInstructionMng.ShippingInstruction, ShippingInstruction>(dtoItem, dbItem);
     dbItem.UpdatedDate = DateTime.Now;
 }