Exemple #1
0
        public TakeDocModel.Folder Create(JObject jfolder)
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                TakeDocModel.Folder folder = new TakeDocModel.Folder();

                Guid entityId       = new Guid(jfolder.Value <string>("entityId"));
                Guid userCreateData = new Guid(jfolder.Value <string>("userCreateId"));
                Guid ownerId        = new Guid(jfolder.Value <string>("ownerId"));
                Guid folderTypeId   = new Guid(jfolder.Value <string>("folderTypeId"));

                TakeDocModel.StatusFolder status  = daoStatusFolder.GetBy(x => x.StatusFolderReference == "OPEN" && x.EntityId == entityId).First();
                TakeDocModel.TypeDocument typeDoc = daoTypeDoc.GetBy(x => x.FolderTypeId == folderTypeId).First();

                folder.FolderLabel    = jfolder.Value <string>("title");
                folder.FolderTypeId   = folderTypeId;
                folder.FolderOwnerId  = ownerId;
                folder.FolderStatusId = status.StatusFolderId;

                folder.FolderDateStart = DateTimeOffset.Parse(jfolder.Value <string>("start"), System.Globalization.CultureInfo.InvariantCulture);
                folder.FolderDateEnd   = DateTimeOffset.Parse(jfolder.Value <string>("end"), System.Globalization.CultureInfo.InvariantCulture);

                daoFolder.Create(folder, userCreateData, entityId);
                servDocument.Create(ownerId, folder.EntityId, typeDoc.TypeDocumentId, folder.FolderLabel, folder.FolderId);
                transaction.Complete();
                return(folder);
            }
        }
Exemple #2
0
        public TakeDocModel.Folder Update(JObject jfolder)
        {
            Guid folderId     = new Guid(jfolder.Value <string>("folderId"));
            Guid entityId     = new Guid(jfolder.Value <string>("entityId"));
            Guid userUpdateId = new Guid(jfolder.Value <string>("userUpdateId"));
            Guid ownerId      = new Guid(jfolder.Value <string>("ownerId"));

            TakeDocModel.Folder folder = daoFolder.GetBy(x => x.FolderId == folderId && x.EntityId == entityId).First();
            if (folder.StatusFolder.StatusFolderReference.Equals("OPEN"))
            {
                folder.FolderLabel    = jfolder.Value <string>("title");
                folder.FolderDetail   = jfolder.Value <string>("detail");
                folder.FolderOwnerId  = ownerId;
                folder.UserUpdateData = userUpdateId;
                folder.DateUpdateData = System.DateTimeOffset.UtcNow;

                if (string.IsNullOrEmpty(jfolder.Value <string>("start")) == false)
                {
                    folder.FolderDateStart = DateTimeOffset.Parse(jfolder.Value <string>("start"), System.Globalization.CultureInfo.InvariantCulture);
                }

                if (string.IsNullOrEmpty(jfolder.Value <string>("end")) == false)
                {
                    folder.FolderDateEnd = DateTimeOffset.Parse(jfolder.Value <string>("end"), System.Globalization.CultureInfo.InvariantCulture);
                }

                daoFolder.Update(folder, userUpdateId, entityId);
            }
            else
            {
                throw new Exception("Impossible de modifier un rendez-vous en cours ou terminé.");
            }

            return(folder);
        }
Exemple #3
0
        public HttpResponseMessage Set(Guid userId, [FromBody] string value)
        {
            try
            {
                Newtonsoft.Json.Linq.JObject data = Newtonsoft.Json.Linq.JObject.Parse(value);
                data.Add("userUpdateId", userId.ToString());
                IFolderService      servFolder = Utility.MyUnityHelper.UnityHelper.Resolve <IFolderService>();
                TakeDocModel.Folder folder     = servFolder.Create(data);

                var json = new
                {
                    id           = folder.FolderId,
                    folderId     = folder.FolderId,
                    title        = folder.FolderLabel,
                    start        = folder.FolderDateStart,
                    end          = folder.FolderDateEnd,
                    allDay       = false,
                    entityId     = folder.EntityId,
                    ownerId      = folder.FolderOwnerId,
                    folderTypeId = folder.FolderTypeId,
                };

                return(Request.CreateResponse(json));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }