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); } }
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); } }