Exemplo n.º 1
0
        public NoteDTO GetNoteEditNew(int parentId)
        {
            var model = new NoteDTO(SourceType)
            {
                ParentID = parentId
            };

            return(model);
        }
Exemplo n.º 2
0
 public static void ToNote(NoteDTO t, BaseNote note)
 {
     note.SetParentId(t.ParentID);
     note.CorrespondenceType = t.CorrespondenceType;
     note.CorrespondenceName = t.CorrespondenceName;
     note.RequiresFollowup   = t.RequiresFollowup;
     note.FollowupDate       = t.FollowupDate;
     note.Comments           = t.Comments;
 }
Exemplo n.º 3
0
        public void SaveNote(NoteDTO model, int userId)
        {
            var exists = model.ID > 0;
            var note   = exists ? GetNoteById(model.ID) : GetSet().Create();

            Mapper.ToNote(model, note);
            if (!exists)
            {
                note.EnteredByUserID = userId;
                note.SetParentId(model.ParentID);
                GetSet().Add(note);
            }
            Context.SaveChanges();
            foreach (var task in model.Tasks)
            {
                switch (task.Action.ToLower())
                {
                case "delete":
                    TasksService.Remove(task.ID);
                    break;

                default:
                    var taskExists = task.ID > 0;
                    var n          = taskExists ? TasksService.GetTask(task.ID) : new NoteTaskDTO(SourceType)
                    {
                        NoteID   = note.ID,
                        ParentID = note.GetParentID()
                    };
                    n.Description = task.Description;
                    n.DueDate     = task.DueDate;
                    n.AssignedTo  = task.AssignedTo;
                    TasksService.Save(n);
                    break;
                }
            }
            Context.SaveChanges();
        }