コード例 #1
0
        //Create template
        public static int Create(TemplateDTO TemplateDTO)
        {
            if (TemplateDTO.Title == null || TemplateDTO.Title == "") { return 0; }

            try
            {
                var Template = new Template();

                GlobalSettings.LoggedInClientId = TemplateDTO.ClientId;
                int PartnerId = ClientService.GetById(TemplateDTO.ClientId).PartnerId;
                GlobalSettings.LoggedInPartnerId = PartnerId;

                UnitOfWork uow = new UnitOfWork();
                Template = Transform.TemplateToDomain(TemplateDTO);
                uow.TemplateRepo.Insert(Template);

                uow.SaveChanges();
                TemplateDTO.Id = Template.Id;
                return TemplateDTO.Id;

            }

            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        //Edit template
        public static void Edit(TemplateDTO TemplateDTO)
        {
            if (TemplateDTO.Title != null || TemplateDTO.Title != "")
            {
                try
                {
                    GlobalSettings.LoggedInClientId = TemplateDTO.ClientId;
                    int PartnerId = ClientService.GetById(TemplateDTO.ClientId).PartnerId;
                    GlobalSettings.LoggedInPartnerId = PartnerId;

                    UnitOfWork uow = new UnitOfWork();
                    Template Template = Transform.TemplateToDomain(TemplateDTO);
                    uow.TemplateRepo.Update(Template);
                    uow.SaveChanges();
                }
                catch
                {
                    throw;
                }
            }
        }
コード例 #3
0
 public void EditTemplate(TemplateDTO oTemplateDTO)
 {
     try
     {
         TemplateService.Edit(oTemplateDTO);
     }
     catch (TimeoutException)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout)
         {
             Content = new StringContent("An error occurred, please try again or contact the administrator."),
             ReasonPhrase = "Critical Exception"
         });
     }
     catch (Exception e)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content = new StringContent("An error occurred, please try again or contact the administrator."),
             ReasonPhrase = "Critical Exception"
         });
     }
 }
コード例 #4
0
        //Get template details by message
        public static TemplateDTO GetTemplateByMessage(string Message)
        {
            try
            {
                TemplateDTO TemplateDTO = new TemplateDTO();
                UnitOfWork uow = new UnitOfWork();
                IEnumerable<Template> Template = uow.TemplateRepo.GetAll().Where(e => e.Message.ToLower() == Message.ToLower() && e.ClientId == GlobalSettings.LoggedInClientId);
                if (Template != null)
                {
                    foreach (var item in Template)
                    {
                        TemplateDTO = Transform.TemplateToDTO(item);
                    }
                }

                return TemplateDTO;
            }
            catch
            {
                throw;
            }
        }
コード例 #5
0
 public static Template TemplateToDomain(TemplateDTO TemplateDTO)
 {
     if (TemplateDTO == null) return null;
      Mapper.CreateMap<TemplateDTO, Template>();
      Template Template = Mapper.Map<Template>(TemplateDTO);
      return Template;
 }