Example #1
0
        private IncomingMailbox ToEntityIncoming(MailboxDocumentModel doc)
        {
            var result = new IncomingMailbox();

            result.DocumentAnnotation  = doc.Annotations;
            result.AssignedByLogin     = doc.AssignedByLogin;
            result.AssignedByName      = doc.AssignedByName;
            result.AssignedToControl   = doc.AssignedToControl;
            result.AssignedToLogin     = doc.AssignedToLogin;
            result.AssignedToName      = doc.AssignedToName;
            result.AssignedToCCName    = doc.AssignedToCCName;
            result.AssignedToCCControl = doc.AssignedToCCControl;
            result.AssignedToCCLogin   = doc.AssignedToCCLogin;
            result.AssignmentDate      = doc.AssignmentDate;
            result.AssignmentStatus    = doc.AssignmentStatus;
            result.IncomingMailboxId   = doc.MailboxDocumentId;
            result.DocumentFrom        = doc.DocumentFrom;
            result.DocumentLibraryId   = doc.DocumentLibraryId;
            result.DocumentTitle       = doc.DocumentTitle;
            result.DocumentUrl         = doc.DocumentUrl;
            result.DocumentDate        = doc.DocumentDate;
            result.DocumentSubject     = doc.DocumentSubject;
            result.ListItemId          = doc.ListItemId;
            result.DocumentSummary     = doc.DocumentSummary;
            result.SiteUrl             = doc.SiteUrl;
            result.ResponseDate        = doc.ResponseDate;
            result.FirstReminderDate   = doc.FirstReminderDate;
            result.SecondReminderDate  = doc.SecondReminderDate;
            return(result);
        }
Example #2
0
        private MailboxDocumentModel ToModelIncoming(IncomingMailbox doc)
        {
            var result = new MailboxDocumentModel();

            result.Annotations         = doc.DocumentAnnotation;
            result.AssignedByLogin     = doc.AssignedByLogin;
            result.AssignedByName      = doc.AssignedByName;
            result.AssignedToControl   = doc.AssignedToControl;
            result.AssignedToLogin     = doc.AssignedToLogin;
            result.AssignedToName      = doc.AssignedToName;
            result.AssignedToCCName    = doc.AssignedToCCName;
            result.AssignedToCCControl = doc.AssignedToCCControl;
            result.AssignedToCCLogin   = doc.AssignedToCCLogin;
            result.AssignmentDate      = doc.AssignmentDate.HasValue ? doc.AssignmentDate.Value : DateTime.MinValue;
            result.AssignmentStatus    = doc.AssignmentStatus;
            result.MailboxDocumentId   = doc.IncomingMailboxId;
            result.DocumentFrom        = doc.DocumentFrom;
            result.DocumentLibraryId   = doc.DocumentLibraryId;
            result.DocumentTitle       = doc.DocumentTitle;
            result.DocumentUrl         = doc.DocumentUrl;
            result.DocumentDate        = doc.DocumentDate.HasValue ? doc.DocumentDate.Value : DateTime.MinValue;
            result.DocumentSubject     = doc.DocumentSubject;
            result.ListItemId          = doc.ListItemId.HasValue ? doc.ListItemId.Value : 0;
            result.DocumentSummary     = doc.DocumentSummary;
            result.SiteUrl             = doc.SiteUrl;
            result.ResponseDate        = doc.ResponseDate.HasValue ? doc.ResponseDate.Value : DateTime.MinValue;
            result.FirstReminderDate   = doc.FirstReminderDate.HasValue ? doc.FirstReminderDate.Value : DateTime.MinValue;
            result.SecondReminderDate  = doc.SecondReminderDate.HasValue ? doc.SecondReminderDate.Value : DateTime.MinValue;
            return(result);
        }
Example #3
0
        public MailboxDocumentModel GetIncomingMailboxById(int id)
        {
            var tmp    = context.IncomingMailbox.FirstOrDefault(x => x.IncomingMailboxId == id);
            var result = new MailboxDocumentModel();

            if (tmp != null)
            {
                result = ToModelIncoming(tmp);
            }
            return(result);
        }
Example #4
0
        public MailboxDocumentModel GetIncomingMailboxByLocation(string siteUrl, string docLibraryId, int itemId, string status)
        {
            var tmp    = context.IncomingMailbox.Where(x => x.SiteUrl == siteUrl && x.DocumentLibraryId == docLibraryId && x.ListItemId == itemId && (string.IsNullOrEmpty(status) || x.AssignmentStatus == status)).OrderByDescending(x => x.AssignmentDate);
            var result = new MailboxDocumentModel();

            if (tmp != null)
            {
                if (tmp.Count() > 0)
                {
                    result = ToModelIncoming(tmp.First());
                }
            }
            return(result);
        }
Example #5
0
        public int SaveIncomingMailbox(MailboxDocumentModel model)
        {
            var result    = 0;
            var tmp       = ToEntityIncoming(model);
            var tmpDetail = new IncomingMailboxDetail();

            tmpDetail.AssignedByLogin    = model.AssignedByLogin;
            tmpDetail.AssignedByName     = model.AssignedByName;
            tmpDetail.AssignedToLogin    = model.AssignedToLogin;
            tmpDetail.AssignedToName     = model.AssignedToName;
            tmpDetail.AssignedToCCLogin  = model.AssignedToCCLogin;
            tmpDetail.AssignedToCCName   = model.AssignedToCCName;
            tmpDetail.AssignmentDate     = model.AssignmentDate;
            tmpDetail.AssignmentStatus   = model.AssignmentStatus;
            tmpDetail.DocumentAnnotation = model.Annotations;
            tmpDetail.AssignmentDueTo    = model.ResponseDate;
            if (model.MailboxDocumentId > 0)
            {
                tmp = context.IncomingMailbox.FirstOrDefault(x => x.IncomingMailboxId == model.MailboxDocumentId);
                if (model.AssignmentStatus == "Asignado")
                {
                    tmp.AssignedByLogin     = model.AssignedByLogin;
                    tmp.AssignedByName      = model.AssignedByName;
                    tmp.AssignedToCCControl = model.AssignedToCCControl;
                    tmp.AssignedToCCLogin   = model.AssignedToCCLogin;
                    tmp.AssignedToCCName    = model.AssignedToCCName;
                    tmp.AssignedToControl   = model.AssignedToControl;
                    tmp.AssignedToLogin     = model.AssignedToLogin;
                    tmp.AssignedToName      = model.AssignedToName;
                    tmp.AssignmentDate      = model.AssignmentDate;
                    tmp.ResponseDate        = model.ResponseDate;
                }
                tmp.DocumentAnnotation = model.Annotations;
                tmp.AssignmentStatus   = model.AssignmentStatus;
            }
            else
            {
                context.IncomingMailbox.Add(tmp);
            }
            context.SaveChanges();
            tmpDetail.IncomingMailboxId = tmp.IncomingMailboxId;
            context.IncomingMailboxDetail.Add(tmpDetail);
            context.SaveChanges();
            result = tmp.IncomingMailboxId;
            return(result);
        }
Example #6
0
        public IHttpActionResult PostIncomingMailbox(MailboxDocumentModel document)
        {
            var result = new PostEntityModelResponse();

            try
            {
                result.ItemId = helper.SaveIncomingMailbox(document);
                if (result.ItemId <= 0)
                {
                    result.Message = "No records were saved.";
                }
            }
            catch (Exception ex)
            {
                result.Message = "An error occured while saving your information.";
            }
            return(Ok(result));
        }
Example #7
0
        public async Task <string> PostInMailbox(MailboxDocumentModel document)
        {
            var    result         = 0;
            string actionEndpoint = "inmailbox/InMailbox";
            PostEntityModelResponse serviceResult = new PostEntityModelResponse();

            using (var client = new HttpClient())
            {
                using (var request = new HttpRequestMessage(HttpMethod.Get, baseEndpoint + actionEndpoint))
                {
                    request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    using (HttpResponseMessage response = await client.PostAsJsonAsync(request.RequestUri, document))
                    {
                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            serviceResult = JsonConvert.DeserializeObject <PostEntityModelResponse>(response.Content.ReadAsStringAsync().Result);
                            result        = serviceResult.ItemId;
                        }
                    }
                }
            }
            return(JsonConvert.SerializeObject(result));
        }
Example #8
0
 public IncomingMailboxViewModel()
 {
     DBModel = new MailboxDocumentModel();
 }