Exemplo n.º 1
0
        public override bool DeleteData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (LeaveRequestMngEntities context = CreateContext())
                {
                    LeaveRequest dbItem = context.LeaveRequest.FirstOrDefault(o => o.LeaveRequestID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "LeaveRequest not found!";
                        return(false);
                    }
                    else
                    {
                        context.LeaveRequest.Remove(dbItem);
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(false);
            }
        }
Exemplo n.º 2
0
 public void DTO2BD(DTO.LeaveRequest dtoItem, ref LeaveRequest dbItem)
 {
     dbItem.FromDate = dtoItem.FromDate.ConvertStringToDateTime();
     dbItem.ToDate   = dtoItem.ToDate.ConvertStringToDateTime();
     AutoMapper.Mapper.Map <DTO.LeaveRequest, LeaveRequest>(dtoItem, dbItem);
 }