コード例 #1
0
ファイル: ToDoTest.cs プロジェクト: rotovibe/engage
        public void InsertToDo_Test()
        {
            ToDoData data = new ToDoData
            {
                AssignedToId = "5325c822072ef705080d3491",
                CategoryId   = "53f51afed4332316fcdbeba3",
                Description  = "to do description 3.",
                DueDate      = System.DateTime.UtcNow,
                StartTime    = DateTime.UtcNow,
                Duration     = 20,
                Title        = "to do title 3.",
                PatientId    = "5325da01d6a4850adcbba4fa",
                PriorityId   = 0,
                ProgramIds   = new System.Collections.Generic.List <string> {
                    "5330920da38116ac180009d2", "532caae9a38116ac18000846"
                },
            };
            PutInsertToDoDataRequest request = new PutInsertToDoDataRequest
            {
                Context        = context,
                ContractNumber = contractNumber,
                ToDoData       = data,
                UserId         = userId,
                Version        = version
            };

            ISchedulingDataManager cm = new SchedulingDataManager {
                Factory = new SchedulingRepositoryFactory()
            };
            PutInsertToDoDataResponse response = cm.InsertToDo(request);

            Assert.IsNotNull(response);
        }
コード例 #2
0
        public object Insert(object newEntity)
        {
            PutInsertToDoDataRequest request = (PutInsertToDoDataRequest)newEntity;
            ToDoData todoData = request.ToDoData;
            string   id       = null;
            METoDo   meToDo   = null;

            try
            {
                if (todoData != null)
                {
                    meToDo = new METoDo(this.UserId, todoData.CreatedOn)
                    {
                        Id           = ObjectId.Parse("532b6320a381168abe000877"),
                        Status       = (Status)todoData.StatusId,
                        Priority     = (Priority)todoData.PriorityId,
                        Description  = todoData.Description,
                        Title        = todoData.Title,
                        LoweredTitle = todoData.Title != null?todoData.Title.ToLower() : null,
                                           DueDate       = todoData.DueDate,
                                           StartTime     = meToDo.StartTime,
                                           Duration      = meToDo.Duration,
                                           DeleteFlag    = false,
                                           AssignedToId  = ObjectId.Parse(todoData.AssignedToId),
                                           SourceId      = ObjectId.Parse(todoData.SourceId),
                                           ClosedDate    = todoData.ClosedDate,
                                           LastUpdatedOn = todoData.UpdatedOn
                    };
                }
                return(meToDo.Id.ToString());
            }
            catch (Exception) { throw; }
        }
コード例 #3
0
        public PutInsertToDoDataResponse InsertToDo(PutInsertToDoDataRequest request)
        {
            PutInsertToDoDataResponse respone = new PutInsertToDoDataResponse();

            try
            {
                ISchedulingRepository repo = Factory.GetRepository(request, RepositoryType.ToDo);
                string toDoId = (string)repo.Insert(request);
                if (!string.IsNullOrEmpty(toDoId))
                {
                    ToDoData data = (ToDoData)repo.FindByID(toDoId);
                    respone.ToDoData = data;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(respone);
        }
コード例 #4
0
        public object PutInsertToDo(ToDoData todo, string userId, IAppDomainRequest req)
        {
            try
            {
                var request = new PutInsertToDoDataRequest();
                request.ToDoData = todo;
                IRestClient client = new JsonServiceClient();

                var url = Common.Helper.BuildURL(string.Format(@"{0}/{1}/{2}/{3}/Scheduling/ToDo/Insert",
                                                               DDSchedulingUrl,
                                                               "NG",
                                                               req.Version,
                                                               req.ContractNumber), userId);

                var response = client.Put <PutInsertToDoDataResponse>(url, request);
                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:PlanElementEndpointUtil:PutInsertToDo()::" + ex.Message, ex.InnerException);
            }
        }
コード例 #5
0
        public PutInsertToDoDataResponse Put(PutInsertToDoDataRequest request)
        {
            PutInsertToDoDataResponse response = new PutInsertToDoDataResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("SchedulingDD:Put()::Unauthorized Access");
                }

                response         = Manager.InsertToDo(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Common.Helper.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }
コード例 #6
0
        public object Insert(object newEntity)
        {
            PutInsertToDoDataRequest request = (PutInsertToDoDataRequest)newEntity;
            ToDoData todoData = request.ToDoData;
            string   id       = null;
            METoDo   meToDo   = null;

            try
            {
                if (todoData != null)
                {
                    meToDo = new METoDo(this.UserId, todoData.CreatedOn)
                    {
                        Status       = (Status)todoData.StatusId,
                        Priority     = (Priority)todoData.PriorityId,
                        Description  = todoData.Description,
                        Title        = todoData.Title,
                        LoweredTitle = todoData.Title != null?todoData.Title.ToLower() : null,
                                           DueDate          = todoData.DueDate,
                                           StartTime        = todoData.StartTime,
                                           Duration         = todoData.Duration,
                                           ProgramIds       = Helper.ConvertToObjectIdList(todoData.ProgramIds),
                                           DeleteFlag       = false,
                                           LastUpdatedOn    = todoData.UpdatedOn,
                                           ExternalRecordId = todoData.ExternalRecordId
                    };

                    if (!string.IsNullOrEmpty(todoData.AssignedToId))
                    {
                        meToDo.AssignedToId = ObjectId.Parse(todoData.AssignedToId);
                    }
                    if (!string.IsNullOrEmpty(todoData.CategoryId))
                    {
                        meToDo.Category = ObjectId.Parse(todoData.CategoryId);
                    }
                    if (!string.IsNullOrEmpty(todoData.PatientId))
                    {
                        meToDo.PatientId = ObjectId.Parse(todoData.PatientId);
                    }
                    if (!string.IsNullOrEmpty(todoData.SourceId))
                    {
                        meToDo.SourceId = ObjectId.Parse(todoData.SourceId);
                    }
                    if (todoData.ClosedDate != null)
                    {
                        meToDo.ClosedDate = todoData.ClosedDate;
                    }

                    using (SchedulingMongoContext ctx = new SchedulingMongoContext(_dbName))
                    {
                        ctx.ToDos.Collection.Insert(meToDo);

                        AuditHelper.LogDataAudit(this.UserId,
                                                 MongoCollectionName.ToDo.ToString(),
                                                 meToDo.Id.ToString(),
                                                 Common.DataAuditType.Insert,
                                                 request.ContractNumber);

                        id = meToDo.Id.ToString();
                    }
                }
                return(id);
            }
            catch (Exception) { throw; }
        }