Ejemplo n.º 1
0
        public DTO.ClientCountryMng.ClientCountry DB2DTO_ClientCountry(ClientCountryMng_ClientCountry_View dbItem)
        {
            DTO.ClientCountryMng.ClientCountry dtoItem = AutoMapper.Mapper.Map <ClientCountryMng_ClientCountry_View, DTO.ClientCountryMng.ClientCountry>(dbItem);

            if (dtoItem == null)
            {
                return(null);
            }

            if (dtoItem.CreatedDate.HasValue)
            {
                dtoItem.CreatedDateFormated = dtoItem.CreatedDate.Value.ToString("dd/MM/yyyy");
            }
            if (dtoItem.UpdatedDate.HasValue)
            {
                dtoItem.UpdatedDateFormated = dtoItem.UpdatedDate.Value.ToString("dd/MM/yyyy");
            }

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

            // continue processing
            BLL.ClientCountryMng bll = new BLL.ClientCountryMng();
            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.ClientCountryMng.ClientCountry>()
            {
                Data = dtoItem, Message = notification
            }));
        }
Ejemplo n.º 3
0
 public void DTO2BD_ClientCountry(DTO.ClientCountryMng.ClientCountry dtoItem, ref ClientCountry dbItem)
 {
     AutoMapper.Mapper.Map <DTO.ClientCountryMng.ClientCountry, ClientCountry>(dtoItem, dbItem);
 }