示例#1
0
 public HttpResponseMessage Update([System.Web.Http.ModelBinding.ModelBinder(typeof(IocCustomCreationConverter))] ISPPrintTemplate printTemplate)
 {
     try
     {
         var result = printTemplateSrv.Update(printTemplate);
         if (string.IsNullOrEmpty(printTemplate.Name))
         {
             if (result)
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.OK, HttpCustomStatus.Success, null, printTemplate.IsActive? GetLocalisedString("msgPrintTemplateActivate") : GetLocalisedString("msgPrintTemplateDeactivate")));
             }
             else
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.NotModified, HttpCustomStatus.Success, null, printTemplate.IsActive ? GetLocalisedString("msgAlreadyActivated") : GetLocalisedString("msgAlreadyDeactivated")));
             }
         }
         else
         {
             if (result)
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.OK, HttpCustomStatus.Success, null, GetLocalisedString("msgPrintTemplateUpdate")));
             }
             else
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.Accepted, HttpCustomStatus.Success, null, GetLocalisedString("msgPrintTemplateDuplicate")));
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.InternalServerError, HttpCustomStatus.Failure, null, GetLocalisedString("msgWebServiceError") + ex.Message));
     }
 }
 public HttpResponseMessage Update([System.Web.Http.ModelBinding.ModelBinder(typeof(IocCustomCreationConverter))] ISPPrintTemplate printTemplate)
 {
     try
     {
         var result = printTemplateSrv.Update(printTemplate);
         if (string.IsNullOrEmpty(printTemplate.Name))
         {
             if (result)
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.OK, HttpCustomStatus.Success, null, string.Format("Template {0} successfully", printTemplate.IsActive ? "activated" : "deactivated")));
             }
             else
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.NotModified, HttpCustomStatus.Success, null, string.Format("Template already {0}", printTemplate.IsActive ? "activated" : "deactivated")));
             }
         }
         else
         {
             if (result)
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.OK, HttpCustomStatus.Success, null, "Template updated successfully"));
             }
             else
             {
                 return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.Accepted, HttpCustomStatus.Success, null, "Name already exists, please try another name"));
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.InternalServerError, HttpCustomStatus.Failure, null, "Web Service Error: Please report this problem or try again later." + ex.Message));
     }
 }
示例#3
0
        public HttpResponseMessage Create([System.Web.Http.ModelBinding.ModelBinder(typeof(IocCustomCreationConverter))] ISPPrintTemplate printTemplate)
        {
            try
            {
                var result = printTemplateSrv.Create(printTemplate);

                if (result != null)
                {
                    return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.Created, HttpCustomStatus.Success, result, GetLocalisedString("msgPrintTemplateCreation")));
                }
                else
                {
                    return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.Accepted, HttpCustomStatus.Success, result, GetLocalisedString("msgPrintTemplateDuplicate")));
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.InternalServerError, HttpCustomStatus.Failure, null, GetLocalisedString("msgWebServiceError") + ex.Message));
            }
        }
        public HttpResponseMessage Create([System.Web.Http.ModelBinding.ModelBinder(typeof(IocCustomCreationConverter))] ISPPrintTemplate printTemplate)
        {
            try
            {
                var result = printTemplateSrv.Create(printTemplate);

                if (result != null)
                {
                    return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.Created, HttpCustomStatus.Success, result, "Template created successfully"));
                }
                else
                {
                    return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.Accepted, HttpCustomStatus.Success, result, "Name already exists, please try another name"));
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                return(CreateHttpResponse <ISPPrintTemplate>(HttpStatusCode.InternalServerError, HttpCustomStatus.Failure, null, "Web Service Error: Please report this problem or try again later." + ex.Message));
            }
        }
        /// <summary>
        /// Update details or status change of print template
        /// </summary>
        /// <param name="printTemplate">print template to be updated</param>
        /// <returns>status of the operation result</returns>
        public bool Update(ISPPrintTemplate printTemplate)
        {
            bool status = false;

            try
            {
                if (string.IsNullOrEmpty(printTemplate.Name))
                {
                    var templateEntity = this.printTemplateSrv.Entities.Where(s => s.Id == printTemplate.Id).FirstOrDefault();

                    if (printTemplate.IsActive != templateEntity.IsActive)
                    {
                        templateEntity.IsActive = !templateEntity.IsActive;
                        this.printTemplateSrv.Update(templateEntity);
                        UnitOfWork.Commit();
                        status = true;
                    }
                }
                else
                {
                    bool exists = this.printTemplateSrv.Entities.Where(s => s.Name.ToLower() == printTemplate.Name.ToLower() && s.Id != printTemplate.Id).Count() > 0 ? true : false;
                    if (!exists)
                    {
                        this.printTemplateSrv.Update(printTemplate);
                        UnitOfWork.Commit();
                        status = true;
                    }
                    else
                    {
                        status = false;
                    }
                }

                return(status);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Create a print template
        /// </summary>
        /// <param name="printTemplate">print template entity</param>
        /// <returns>created print template</returns>
        public ISPPrintTemplate Create(ISPPrintTemplate printTemplate)
        {
            try
            {
                bool exists = this.printTemplateSrv.Entities.Where(s => s.Name.ToLower() == printTemplate.Name.ToLower()).Count() > 0 ? true : false;
                if (!exists)
                {
                    printTemplate = this.printTemplateSrv.Add(printTemplate);
                    UnitOfWork.Commit();
                }
                else
                {
                    printTemplate = null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(printTemplate);
        }
 /// <summary>
 /// Update template details or status change of print template
 /// </summary>
 /// <param name="printTemplate">print template to be updated</param>
 /// <returns>status of operation result</returns>
 public bool Update(ISPPrintTemplate printTemplate)
 {
     return(this.printTemplateSrv.Update(printTemplate));
 }
 /// <summary>
 /// Create a print template
 /// </summary>
 /// <param name="printTemplate">print template entity</param>
 /// <returns>created print template</returns>
 public ISPPrintTemplate Create(ISPPrintTemplate printTemplate)
 {
     return(this.printTemplateSrv.Create(printTemplate));
 }