Ejemplo n.º 1
0
        public HttpResponseMessage PutCitizen_FollowUps(Guid followup_id, FollowupData followUp)
        {
            try
            {
                DateTime updatedTimestamp = DateTime.Now;

                Citizen_FollowUps citizenFollowUp = (from p in db.Citizen_FollowUps
                                                     where p.GUID == followup_id
                                                     select p).FirstOrDefault();


                citizenFollowUp.NextFollowupdate = followUp.NextFollowupdate;
                citizenFollowUp.Log_from         = updatedTimestamp;
                citizenFollowUp.Log_UserId       = followUp.Log_UserId;

                List <Citizen_FollowUpAttachments> maps = (from p in db.Citizen_FollowUpAttachments
                                                           where p.FollowupId == followup_id
                                                           select p).ToList();

                if (maps.Count > 0)
                {
                    foreach (Citizen_FollowUpAttachments item in maps)
                    {
                        db.Citizen_FollowUpAttachments.Remove(item);
                    }
                }

                if (followUp.attachments.Length > 0)
                {
                    foreach (Attachments item in followUp.attachments)
                    {
                        Citizen_FollowUpAttachments followupAttachments = new Citizen_FollowUpAttachments
                        {
                            GUID             = Guid.NewGuid(),
                            Createdtimestamp = updatedTimestamp,
                            Log_UserId       = followUp.Log_UserId,
                            CitizenId        = followUp.CitizenId,
                            FollowupId       = followup_id,
                            DocType          = item.DocType,
                            Docname          = item.Docname,
                            Objectid         = item.Objectid
                        };
                        db.Citizen_FollowUpAttachments.Add(followupAttachments);
                    }
                }


                db.SaveChanges();

                var httpResponseMessage = new HttpResponseMessage();
                httpResponseMessage.Content = new StringContent(JsonConvert.SerializeObject("true"));
                httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                return(httpResponseMessage);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetCitizen_FollowUps(Guid citizenid)
        {
            try
            {
                Citizen_FollowUps followUp = (from p in db.Citizen_FollowUps
                                              where p.CitizenId == citizenid
                                              select p).FirstOrDefault();

                if (followUp != null)
                {
                    Guid?[] items = (from c in db.Citizen_FollowUpAttachments
                                     where c.FollowupId == followUp.GUID
                                     select c.Objectid
                                     ).ToArray();


                    FollowupData final = new FollowupData
                    {
                        GUID             = followUp.GUID,
                        CitizenId        = followUp.CitizenId,
                        Createdtimestamp = followUp.Createdtimestamp,
                        NextFollowupdate = followUp.NextFollowupdate
                    };
                    List <FollowupAtatchedNotes> attachments = new List <FollowupAtatchedNotes>();

                    if (items.Length > 0)
                    {
                        foreach (Guid?attachmentGUID in items)
                        {
                            if (attachmentGUID == null)
                            {
                                final.IsDocumentA = true;
                            }
                            else
                            {
                                var doc = (from d in db.Documents
                                           where d.GUID == attachmentGUID
                                           select d).FirstOrDefault();

                                FollowupAtatchedNotes note = new FollowupAtatchedNotes
                                {
                                    GUID             = doc.GUID,
                                    Createdtimestamp = doc.Createdtimestamp,
                                    Description      = doc.Description,
                                    DocumentType     = doc.DocumentType
                                };

                                attachments.Add(note);
                            }
                        }
                    }

                    final.noteAttachments = attachments.ToArray();

                    var httpResponseMessage = new HttpResponseMessage();
                    httpResponseMessage.Content = new StringContent(JsonConvert.SerializeObject(final));
                    httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                    return(httpResponseMessage);
                }
                else
                {
                    var httpResponseMessage = new HttpResponseMessage();
                    httpResponseMessage.Content = new StringContent(JsonConvert.SerializeObject("false"));
                    httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                    return(httpResponseMessage);
                }
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public HttpResponseMessage PostCitizen_FollowUps(FollowupData followUp)
        {
            var httpResponseMessage = new HttpResponseMessage();

            DateTime updatedTimestamp = DateTime.Now;
            Guid     followupID       = Guid.NewGuid();

            Citizen_FollowUps citizenFollowup = new Citizen_FollowUps
            {
                GUID                  = followupID,
                Createdtimestamp      = updatedTimestamp,
                Log_from              = updatedTimestamp,
                Log_UserId            = followUp.Log_UserId,
                CitizenId             = followUp.CitizenId,
                NextFollowupdate      = followUp.NextFollowupdate,
                Description           = null,
                Consent               = null,
                CaseWorkerdescription = null,
                StatusNoteID          = followUp.StatusNoteID,
                Result                = null,
                Deleted               = false
            };

            db.Citizen_FollowUps.Add(citizenFollowup);

            if (followUp.attachments.Length > 0)
            {
                foreach (Attachments item in followUp.attachments)
                {
                    Citizen_FollowUpAttachments followupAttachments = new Citizen_FollowUpAttachments
                    {
                        GUID             = Guid.NewGuid(),
                        Createdtimestamp = updatedTimestamp,
                        Log_UserId       = followUp.Log_UserId,
                        CitizenId        = followUp.CitizenId,
                        FollowupId       = followupID,
                        DocType          = item.DocType,
                        Docname          = item.Docname,
                        Objectid         = item.Objectid
                    };

                    db.Citizen_FollowUpAttachments.Add(followupAttachments);
                }
            }


            var deadline = (from p in db.Deadlines
                            where p.CitizenId == followUp.CitizenId && p.DeadlineColorEnum == 3
                            select p).FirstOrDefault();

            if (deadline != null)
            {
                deadline.Completedby       = followUp.Log_UserId;
                deadline.DeadlineColorEnum = 2;
                deadline.DeadlineDate      = followUp.NextFollowupdate;
                deadline.CompletedDate     = updatedTimestamp;
                deadline.Log_from          = updatedTimestamp;
                deadline.Log_UserId        = followUp.Log_UserId;
                deadline.Title             = "Opfølgning på indsatsmål";
            }

            try
            {
                db.SaveChanges();
                httpResponseMessage.Content = new StringContent(JsonConvert.SerializeObject(followupID));
                httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                return(httpResponseMessage);
            }
            catch
            {
                httpResponseMessage.Content = new StringContent(JsonConvert.SerializeObject("false"));
                httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                return(httpResponseMessage);
            }
        }