コード例 #1
0
        public async Task <TemplateResponse> GetTemplate(TemplateRequest templateRequest)
        {
            try
            {
                templateResponse = new TemplateResponse();

                using (FacepinpointDBEntities db = new FacepinpointDBEntities())
                {
                    var objectContext = ((IObjectContextAdapter)db).ObjectContext;
                    var command       = db.Database.Connection.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT public.\"fn_getEmailTemplate\"('" + templateRequest.TName + "'," + templateRequest.UserId + " , '" + templateRequest.UserEmail + "')";
                    db.Database.Connection.Open();
                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        var result = ((IObjectContextAdapter)db).ObjectContext.Translate <string>(reader).ToList();
                        templateResponse.emailTemplate = result.FirstOrDefault();
                    }
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                templateResponse.Success = false;
                templateResponse.Message = CustomErrorMessages.INTERNAL_ERROR;
            }
            return(templateResponse);
        }
コード例 #2
0
        public async Task <HttpResponseMessage> Create(MT_Surgical_Procedure_Templates SPMD)
        {
            Db = con.SurgeryCenterDb(SPMD.Slug);
            TemplateResponse Response = new TemplateResponse();

            try
            {
                UniqueID              = con.GetUniqueKey();
                SPMD.SPT_Unique_ID    = UniqueID;
                SPMD.SPT_Surgery_Date = con.ConvertTimeZone(SPMD.SPT_TimeZone, Convert.ToDateTime(SPMD.SPT_Surgery_Date));
                SPMD.SPT_Create_Date  = con.ConvertTimeZone(SPMD.SPT_TimeZone, Convert.ToDateTime(SPMD.SPT_Create_Date));
                SPMD.SPT_Modify_Date  = con.ConvertTimeZone(SPMD.SPT_TimeZone, Convert.ToDateTime(SPMD.SPT_Modify_Date));
                DocumentReference docRef = Db.Collection("MT_Surgical_Procedure_Templates").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(SPMD);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = SPMD;
                }
                else
                {
                    Response.Status  = con.StatusNotInsert;
                    Response.Message = con.MessageNotInsert;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
        public void GetEmailTemplateWithId()
        {
            TemplateResponse template = this.client.GetTemplateById(EMAIL_TEMPLATE_ID);

            Assert.AreEqual(template.id, EMAIL_TEMPLATE_ID);
            Assert.AreEqual(template.body, TEST_TEMPLATE_EMAIL_BODY);
        }
コード例 #4
0
        public async Task <HttpResponseMessage> GetTemplateFilterWithSurgeon(MT_Surgical_Procedure_Templates SPMD)
        {
            Db = con.SurgeryCenterDb(SPMD.Slug);
            TemplateResponse Response = new TemplateResponse();

            try
            {
                List <MT_Surgical_Procedure_Templates> TempList = new List <MT_Surgical_Procedure_Templates>();
                Query         ObjQuery     = Db.Collection("MT_Surgical_Procedure_Templates").WhereEqualTo("SPT_Is_Active", true).WhereEqualTo("SPT_Is_Deleted", false).WhereEqualTo("SPT_Surgeon_Name", SPMD.SPT_Surgeon_Name).WhereEqualTo("SPT_Surgery_Physician_Center_ID", SPMD.SPT_Surgery_Physician_Center_ID).OrderBy("SPT_Template_Name");
                QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnap in ObjQuerySnap.Documents)
                    {
                        TempList.Add(Docsnap.ConvertTo <MT_Surgical_Procedure_Templates>());
                    }
                    Response.Status   = con.StatusSuccess;
                    Response.Message  = con.MessageSuccess;
                    Response.DataList = TempList;
                }
                else
                {
                    Response.Status  = con.StatusDNE;
                    Response.Message = con.MessageDNE;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
コード例 #5
0
        public async Task <HttpResponseMessage> Select(MT_Surgical_Procedure_Templates SPMD)
        {
            Db = con.SurgeryCenterDb(SPMD.Slug);
            TemplateResponse Response = new TemplateResponse();

            try
            {
                Query         ObjQuery     = Db.Collection("MT_Surgical_Procedure_Templates").WhereEqualTo("SPT_Is_Active", true).WhereEqualTo("SPT_Is_Deleted", false).WhereEqualTo("SPT_Unique_ID", SPMD.SPT_Unique_ID);
                QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = ObjQuerySnap.Documents[0].ConvertTo <MT_Surgical_Procedure_Templates>();
                }
                else
                {
                    Response.Status  = con.StatusDNE;
                    Response.Message = con.MessageDNE;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
コード例 #6
0
        public async Task <HttpResponseMessage> Remove(MT_Surgical_Procedure_Templates SPMD)
        {
            Db = con.SurgeryCenterDb(SPMD.Slug);
            TemplateResponse Response = new TemplateResponse();

            try
            {
                DocumentReference docRef = Db.Collection("MT_Surgical_Procedure_Templates").Document(SPMD.SPT_Unique_ID);
                WriteResult       Result = await docRef.DeleteAsync();

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = SPMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
        public async Task GetSMSTemplateWithId()
        {
            TemplateResponse template = await this.client.GetTemplateByIdAsync(SMS_TEMPLATE_ID);

            Assert.AreEqual(template.id, SMS_TEMPLATE_ID);
            Assert.AreEqual(template.body, TEST_TEMPLATE_SMS_BODY);
        }
        public async Task GetEmailTemplateWithId()
        {
            TemplateResponse template = await this.client.GetTemplateByIdAsync(EMAIL_TEMPLATE_ID);

            Assert.AreEqual(template.id, EMAIL_TEMPLATE_ID);
            Assert.AreEqual(template.body, TEST_TEMPLATE_EMAIL_BODY);
        }
        public void GetSMSTemplateWithId()
        {
            TemplateResponse template = this.client.GetTemplateById(SMS_TEMPLATE_ID);

            Assert.AreEqual(template.id, SMS_TEMPLATE_ID);
            Assert.AreEqual(template.body, TEST_TEMPLATE_SMS_BODY);
        }
        public void GetLetterTemplateWithIdCheckContactBlock()
        {
            TemplateResponse template = this.client.GetTemplateById(LETTER_TEMPLATE_ID);

            Assert.AreEqual(template.id, LETTER_TEMPLATE_ID);
            Assert.AreEqual(template.letter_contact_block, TEST_LETTER_CONTACT_BLOCK);
        }
コード例 #11
0
        public async Task <TemplateResponse> GetTemplateDetail(int templateId)
        {
            var template = await _customTemplateRepository.FindByIdAsync(templateId);

            if (template == null)
            {
                return(new TemplateResponse());
            }
            var templateDetail = new TemplateResponse
            {
                Id           = template.Id,
                TemplateName = template.TemplateName,
                Tabs         = template.CustomTabs.Select(x => new TabResponse
                {
                    TabId       = x.Id,
                    TabName     = x.Name,
                    AddedBy     = "vijay",
                    AddedOn     = x.AddedDate,
                    ModifiedBy  = x.ModifiedBy == default(int) ? null : "vijayk",
                    ModifiedOn  = x.ModifiedDate,
                    IsVisible   = x.IsVisible,
                    FieldsCount = x.CustomFields.Count,
                    Fields      = x.CustomFields.Select(ctf => new FieldResponse
                    {
                        ModifiedOn   = ctf.ModifiedDate,
                        ModifiedBy   = ctf.ModifiedBy == default(int) ? null : "vijayk",
                        AddedOn      = ctf.AddedDate,
                        AddedBy      = "vijayk",
                        TabId        = ctf.CustomTabId,
                        Value        = ctf.DefaultValue,
                        FieldCaption = ctf.FieldName,
                        FieldName    = $"fieldId_{ctf.Id}",
                        FieldId      = ctf.Id,
                        IsRequired   = ctf.IsMandatory.GetValueOrDefault(),
                        IsVisible    = ctf.IsVisible.GetValueOrDefault(),
                        FieldType    = ctf.FieldType.Caption
                    }).ToHashSet()
                }).ToHashSet(),
                Fields = template.CustomFields.Select(cf => new FieldResponse
                {
                    ModifiedOn   = cf.ModifiedDate,
                    ModifiedBy   = cf.ModifiedBy == default(int) ? null : "vijayk",
                    AddedOn      = cf.AddedDate,
                    AddedBy      = "vijayk",
                    TabId        = cf.CustomTabId,
                    Value        = cf.DefaultValue,
                    FieldCaption = cf.FieldName,
                    FieldName    = $"fieldId_{cf.Id}",
                    FieldId      = cf.Id,
                    IsRequired   = cf.IsMandatory.GetValueOrDefault(),
                    IsVisible    = cf.IsVisible.GetValueOrDefault(),
                    FieldType    = cf.FieldType.Caption
                }).ToHashSet()
            };

            return(templateDetail);
        }
        public void GetTemplateWithIdReceivesExpectedResponse()
        {
            TemplateResponse expectedResponse = JsonConvert.DeserializeObject <TemplateResponse>(Constants.fakeTemplateResponseJson);

            mockRequest(Constants.fakeTemplateResponseJson);

            TemplateResponse responseTemplate = client.GetTemplateById(Constants.fakeTemplateId);

            Assert.IsTrue(expectedResponse.EqualTo(responseTemplate));
        }
コード例 #13
0
        public TemplateResponse GetTemplates()
        {
            var response = new TemplateResponse
            {
                Templates = db.Templates.Select(t => new Template {
                    wassaya = t.Wassaya_Template, Id = t.Id
                }).ToList()
            };

            return(response);
        }
コード例 #14
0
        public async Task <HttpResponseMessage> Update(MT_Surgical_Procedure_Templates SPMD)
        {
            Db = con.SurgeryCenterDb(SPMD.Slug);
            TemplateResponse Response = new TemplateResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "SPT_Template_Name", SPMD.SPT_Template_Name },
                    { "SPT_Surgical_Center_Name", SPMD.SPT_Surgical_Center_Name },
                    { "SPT_Surgeon_Name", SPMD.SPT_Surgeon_Name },
                    { "SPT_Co_Surgeon_Name", SPMD.SPT_Co_Surgeon_Name },
                    { "SPT_Surgery_Date", SPMD.SPT_Surgery_Date },
                    { "SPT_Surgery_Time", SPMD.SPT_Surgery_Time },
                    { "SPT_Surgery_Duration", SPMD.SPT_Surgery_Duration },
                    { "SPT_Anesthesia_Type", SPMD.SPT_Anesthesia_Type },
                    { "SPT_Block", SPMD.SPT_Block },
                    { "SPT_Procedure_SelectedList", SPMD.SPT_Procedure_SelectedList },
                    { "SPT_CPT_SelectedList", SPMD.SPT_CPT_SelectedList },
                    { "SPT_ICD_SelectedList", SPMD.SPT_ICD_SelectedList },
                    { "SPT_Surgery_Physician_Center_ID", SPMD.SPT_Surgery_Physician_Center_ID },
                    { "SPT_Surgery_Physician_Center_Name", SPMD.SPT_Surgery_Physician_Center_Name },
                    { "SPI_Created_By", SPMD.SPI_Created_By },
                    { "SPI_User_Name", SPMD.SPI_User_Name },
                    { "SPT_Modify_Date", con.ConvertTimeZone(SPMD.SPT_TimeZone, Convert.ToDateTime(SPMD.SPT_Modify_Date)) },
                    { "SPT_TimeZone", SPMD.SPT_TimeZone }
                };

                DocumentReference docRef = Db.Collection("MT_Surgical_Procedure_Templates").Document(SPMD.SPT_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = SPMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
コード例 #15
0
        TemplateResponse GetTemplateFromURL(String url)
        {
            String response = this.GET(url);

            try
            {
                TemplateResponse template = JsonConvert.DeserializeObject <TemplateResponse>(response);
                return(template);
            }
            catch (JsonReaderException)
            {
                throw new NotifyClientException("Could not create Template object from response: {0}", response);
            }
        }
コード例 #16
0
 public static void AssertTemplateResponse(TemplateResponse template, String type = null)
 {
     Assert.IsNotNull(template);
     Assert.IsNotNull(template.id);
     Assert.IsNotNull(template.name);
     Assert.IsNotNull(template.version);
     Assert.IsNotNull(template.type);
     if (template.type.Equals("email") || (!string.IsNullOrEmpty(type) && type.Equals("email")))
     {
         Assert.IsNotNull(template.subject);
     }
     Assert.IsNotNull(template.created_at);
     Assert.IsNotNull(template.created_by);
     Assert.IsNotNull(template.body);
 }
コード例 #17
0
            public When_i_request_current_version_of_template()
            {
                _templateVersion = new TemplateVersion
                {
                    Name            = "Test Name",
                    TemplateId      = "123",
                    TemplateJson    = null,
                    Version         = 0,
                    SchemaVersion   = "1.1",
                    Status          = TemplateStatus.Draft,
                    Author          = new Reference("111", "FirstTestUser"),
                    FundingPeriodId = "12345"
                };
                _template = new Template
                {
                    TemplateId    = _templateVersion.TemplateId,
                    Name          = _templateVersion.Name,
                    Description   = "Description",
                    FundingPeriod = new FundingPeriod
                    {
                        Id   = "2021",
                        Name = "Test Period",
                        Type = FundingPeriodType.FY
                    },
                    FundingStream = new FundingStream
                    {
                        Id        = "XX",
                        ShortName = "XX",
                        Name      = "FundingSteam"
                    },
                    Current = _templateVersion
                };
                _templateRepository = Substitute.For <ITemplateRepository>();
                _templateRepository.GetTemplate(Arg.Is(_template.TemplateId)).Returns(_template);

                _service = new TemplateBuilderService(
                    Substitute.For <IIoCValidatorFactory>(),
                    Substitute.For <IFundingTemplateValidationService>(),
                    Substitute.For <ITemplateMetadataResolver>(),
                    Substitute.For <ITemplateVersionRepository>(),
                    _templateRepository,
                    Substitute.For <ISearchRepository <TemplateIndex> >(),
                    Substitute.For <IPolicyRepository>(),
                    Substitute.For <ITemplateBlobService>(),
                    Substitute.For <ILogger>());

                _result = _service.GetTemplate(_template.TemplateId).GetAwaiter().GetResult();
            }
        public async Task <IActionResult> GetTemplate([FromRoute] string templateId)
        {
            if (string.IsNullOrWhiteSpace(templateId))
            {
                return(new BadRequestObjectResult("Null or empty template id"));
            }

            TemplateResponse result = await _templateBuilderService.GetTemplate(templateId);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
コード例 #19
0
        public TemplateResponse GetTemplateByGuid(Guid id)
        {
            TemplateResponse oSingleTemplateResponse = new TemplateResponse();

            {
                TemplatesBL oTemplatesBL = new TemplatesBL();
                Templates   oTemplates   = new Templates();
                ServerResponse.ResponseCodes eResponse = oTemplatesBL.GetTemplateByTemplateGuid(out oTemplates, id);
                oSingleTemplateResponse.data = new singleTemplateresponse {
                    Template = oTemplates
                };
                oSingleTemplateResponse.meta.error_message = ServerResponse.GetResponse(eResponse);
                oSingleTemplateResponse.meta.code          = Convert.ToInt32(eResponse);
            }
            return(oSingleTemplateResponse);
        }
コード例 #20
0
        public async Task <HttpResponseMessage> IsDeleted(MT_Surgical_Procedure_Templates SPMD)
        {
            Db = con.SurgeryCenterDb(SPMD.Slug);
            TemplateResponse Response = new TemplateResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "SPT_Is_Deleted", SPMD.SPT_Is_Deleted },
                    { "SPT_Modify_Date", con.ConvertTimeZone(SPMD.SPT_TimeZone, Convert.ToDateTime(SPMD.SPT_Modify_Date)) },
                    { "SPT_TimeZone", SPMD.SPT_TimeZone }
                };

                DocumentReference docRef = Db.Collection("MT_Surgical_Procedure_Templates").Document(SPMD.SPT_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = SPMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
コード例 #21
0
 public void TestTemplateResponse()
 {
     TemplateResponse response = new TemplateResponse();
      IList<string> lines = new List<string> { "mod1/", "/usr/local/cvsroot/sandbox/mod1/file1.cs", "/file1.cs/1.2.3.4///", "u=rw,g=rw,o=rw", "74" };
      string contents = "/1 :pserver:abougie@gb-aix-q:2401/usr/local/cvsroot/sandbox AB4%o=wSobI4w\n";
      ResponseTest(response, ResponseType.Template, 5, "/usr/local/cvsroot/sandbox/mod1/file1.cs", lines, contents);
 }