Пример #1
0
        public IHttpActionResult Update(QuotationTemplateModel Model)
        {
            try
            {
                QuotationTemplate template = new QuotationTemplate();
                template.Id           = Model.Id;
                template.Name         = Model.Name;
                template.Body         = Model.Body;
                template.ModifiedBy   = Model.ModifiedBy;
                template.ModifiedDate = DateTime.Now.ToUniversalTime();

                using (AppDBContext context = new AppDBContext())
                {
                    var repo = new QuotationTemplateRepository(context);
                    repo.Update(template);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(typeof(QuotationTemplateController), ex.Message + ex.StackTrace, LogType.ERROR);
                return(InternalServerError(ex));
            }

            return(Ok());
        }
Пример #2
0
        public IHttpActionResult GetTemplateById(long Id)
        {
            QuotationTemplateModel model = null;

            try
            {
                using (AppDBContext context = new AppDBContext())
                {
                    var template = new QuotationTemplateRepository(context).GetById(Id);
                    model = new QuotationTemplateModel
                    {
                        Id         = template.Id,
                        Name       = template.Name,
                        CompanyId  = template.CompanyId,
                        Body       = template.Body,
                        ValidityId = template.ValidityId
                    };
                }
            }
            catch (Exception ex)
            {
                Logger.Log(typeof(QuotationTemplateController), ex.Message + ex.StackTrace, LogType.ERROR);
                return(InternalServerError(ex));
            }

            return(Ok(model));
        }