Esempio n. 1
0
        public ActionResult CancelPolicy(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                var entity = Uow.Policies.GetById((int)id);
                if (entity == null)
                {
                    return(HttpNotFound());
                }

                entity.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName("cancelled");
                Uow.Policies.Update(entity);
                Uow.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(RedirectToAction("Details", new { id = id }));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adaptor function (action with no return value) for invoking the Web Service layer
        /// </summary>
        /// <typeparam name="IWebService"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="wsCallExpression"></param>
        protected void InvokeWebService <TWebService, TChannel, TResult>(Expression <Action <TChannel> > wsCallExpression, Action <Exception> exceptionHandler = null, bool isNtmlCreditalRequire = false)
            where TWebService : ClientBase <TChannel>, TChannel, new()
            where TChannel : class
        {
            try
            {
                var tClient = CreateServiceInstance <TWebService, TChannel>(isNtmlCreditalRequire);
                wsCallExpression.Compile().Invoke(tClient);
            }
            catch (Exception ex)
            {
                if (exceptionHandler != null)
                {
                    exceptionHandler.Invoke(ex);
                }
                else
                {
                    var msg = string.Format("Exception in Service Gateway -> {0} -> {1}: {2}",
                                            typeof(TChannel).ToString(), wsCallExpression.ToString(), ex.Message);
                    LoggingSvc.Log(new Exception(msg, ex), category: Category.Web);

                    throw;
                }
            }
        }
Esempio n. 3
0
        public ActionResult Create(ClientModel model)
        {
            try
            {
                var entity = AutoMapper.Mapper.Map <Client>(model);
                Uow.Clients.Add(entity);
                Uow.SaveChanges();

                LogAdd(entity);

                if (string.IsNullOrEmpty(model.ReturnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Redirect(model.ReturnUrl));
                }
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(View(model));
            }
        }
Esempio n. 4
0
        public ActionResult RenewPolicy(PolicyModel model)
        {
            try
            {
                var origEntity = Uow.Policies.GetById(model.Id);
                var entity     = AutoMapper.Mapper.Map <Policy>(model);

                entity.Id = 0;
                entity.RenewalPolicyNumber = origEntity.PolicyNumber;
                entity.DateIssued          = DateTime.Now;

                entity.StatusId     = AttributeProviderSvc.GetPolicyStatusIdFromName("active");
                origEntity.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName("expired");

                Uow.Policies.Add(entity);
                Uow.Policies.Update(origEntity);
                Uow.SaveChanges();

                return(RedirectToAction("Details", new { id = entity.Id }));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(RedirectToAction("Details", new { id = model.Id }));
            }
        }
Esempio n. 5
0
        public ActionResult Create(FormViewModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                SaveFile(model.NewForm, fileUpload);

                Form entity = AutoMapper.Mapper.Map <Form>(model.NewForm);
                Uow.Forms.Add(entity);
                Uow.SaveChanges();

                //LogAdd(entity);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 6
0
        public ActionResult CreateAttachment(PolicyDetailModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                model.NewAttachment.PolicyId = model.Id;
                SaveFile(model.NewAttachment, fileUpload);

                PolicyAttachment entity = AutoMapper.Mapper.Map <PolicyAttachment>(model.NewAttachment);
                entity.PolicyId   = model.Id;
                entity.PostedDate = DateTime.Now;
                Uow.PolicyAttachments.Add(entity);
                Uow.SaveChanges();

                return(RedirectToAction("Details", "Policy", new { id = model.Id }));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(RedirectToAction("Details", "Policy", new { id = model.Id }));
            }
        }
Esempio n. 7
0
        public ActionResult Create(InvoiceModel model)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                model.StatusId = AttributeProviderSvc.GetInvoiceStatusIdFromName("pending");;

                var entity = AutoMapper.Mapper.Map <Invoice>(model);
                Uow.Invoices.Add(entity);
                Uow.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(View());
            }
        }
Esempio n. 8
0
        protected TResult InvokeWebService <TWebService, TChannel, TResult>(Expression <Func <TChannel, TResult> > wsCallExpression, Action <Exception> exceptionHandler = null, bool isNtmlCreditalRequire = false)
            where TWebService : ClientBase <TChannel>, TChannel, new()
            where TChannel : class
        {
            TResult result = default(TResult);

            try
            {
                var tClient = CreateServiceInstance <TWebService, TChannel>(isNtmlCreditalRequire);

                // SP:  Comment Service Gateway performance diagnostics since we are using TPL
                //var timer = new System.Diagnostics.Stopwatch();
                //timer.Start();
                result = wsCallExpression.Compile().Invoke(tClient);
                ////timer.Stop();

                //var msg = string.Format("PerformanceDiagnostics | {0} | {1} | {2}", "Service Invocation", wsCallExpression.ToString(), timer.ElapsedMilliseconds);
                //LoggingSvc.Log(msg, category: Category.BPM, severity: System.Diagnostics.TraceEventType.Verbose);
            }
            catch (Exception ex)
            {
                if (exceptionHandler != null)
                {
                    exceptionHandler.Invoke(ex);
                }
                else
                {
                    var msg = string.Format("Exception in Service Gateway -> {0} -> {1}: {2}",
                                            typeof(TChannel).ToString(), wsCallExpression.ToString(), ex.Message);
                    LoggingSvc.Log(new Exception(msg, ex), category: Category.Web);

                    throw;
                }
            }
            return(result);
        }
Esempio n. 9
0
        public ActionResult EditEndorsement(PolicyDetailModel policyDetailModel, int id)
        {
            try
            {
                var model = policyDetailModel.Endt;
                if (model.IsRet)
                {
                    model.EndorsementAmount *= -1;
                }
                var entity = AutoMapper.Mapper.Map <Endorsement>(model);
                Uow.Endorsements.Update(entity);

                UpdatePolicyAndInvoices(model);
                Uow.SaveChanges();

                return(RedirectToAction("Details", new { id = model.PolicyId }));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                var model = policyDetailModel.Endt;
                return(RedirectToAction("Details", new { id = model.PolicyId }));
            }
        }