public async Task <ActionResult> NewRisksmartPropertyClaim(RisksmartPropertyClaim claim, IEnumerable <string> Region, IEnumerable <string> Incident_Category, IEnumerable <HttpPostedFileBase> upfiles)
        {
            try
            {
                pickListServices = new PicklistServicecs();
                claimServices    = new ClaimServices();
                client           = Session[SessionHelper.claimTeamLogin] as ClaimTeamLoginModel;

                if (claim.Region != null)
                {
                    claim.Region = String.Join(",", Region.Where(s => !string.IsNullOrEmpty(s)));
                }
                if (claim.Incident_Category != null)
                {
                    claim.Incident_Category = String.Join(",", Incident_Category.Where(s => !string.IsNullOrEmpty(s)));
                }

                Mapper.Initialize(cfg => cfg.CreateMap <RisksmartPropertyClaim, ClaimGeneral>());
                ClaimGeneral generalClaim = Mapper.Map <ClaimGeneral>(claim);

                if (ModelState.IsValid)
                {
                    claimServices = new ClaimServices();
                    generalClaim.Claim_Team_Name     = claim.Claim_Team;
                    generalClaim.Accountid           = claim.Accountid;
                    generalClaim.Account_Name        = claim.Account_Name;
                    generalClaim.Claim_Received      = true;
                    generalClaim.Claim_Received_Date = DateTime.Today;
                    var result = await claimServices.TeamInsertClaimNotification(generalClaim, client.UserId, upfiles);

                    if (result.IsSuccess)
                    {
                        TempData["SuccessMsg"] = Messages.successMessage;

                        return(RedirectToAction("index", "claimlist"));
                        //if (claim.Claim_Type == ClaimType.Claim.ToString())
                        //    return RedirectToAction("ViewClaims", "ViewPages");
                        //else
                        //    return RedirectToAction("ViewNotifications", "ViewPages");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            InitializeModel(claim, claimServices);

            return(View(claim));
        }
Пример #2
0
        public async Task <ActionResult> DetailRisksmartGccClaim(RisksmartGccClaim model, IEnumerable <string> Incident_Category, IEnumerable <string> Bodily_Location)
        {
            Session[SessionHelper.StoreobjectList] = null;
            PicklistServicecs picklistService = new PicklistServicecs();
            ClaimServices     claims          = new ClaimServices();

            if (Incident_Category != null)
            {
                model.Incident_Category = String.Join(", ", Incident_Category.Where(s => !string.IsNullOrEmpty(s)));
            }

            if (Bodily_Location != null)
            {
                model.Bodily_Location = String.Join(", ", Bodily_Location.Where(s => !string.IsNullOrEmpty(s)));
            }

            Mapper.Initialize(cfg => cfg.CreateMap <RisksmartGccClaim, ClaimGeneral>());
            ClaimGeneral generalClaim = Mapper.Map <ClaimGeneral>(model);

            generalClaim.Policy_Class = string.IsNullOrEmpty(model.Policy_Class) == true ? model.Policy_Class_Selection : model.Policy_Class;


            ClaimTeamLoginModel login = Session[SessionHelper.claimTeamLogin] as ClaimTeamLoginModel;

            if (ModelState.IsValid)
            {
                claims = new ClaimServices();
                var result = await claims.TeamUpdateClaimNotification(generalClaim, login.UserId);

                if (result)
                {
                    //return RedirectToAction("Index", "ClaimList");
                    TempData["ClaimSaved"] = Messages.ClaimSaved;
                    return(Redirect(Request.UrlReferrer.ToString()));
                }
                else
                {
                    TempData["ErrorMsg"] = Messages.errorMessage;
                }
            }

            InitializeModel(model, claims);

            return(View(model));
        }
Пример #3
0
        //public bool TeamUpdateClaimNotification(ClaimGeneral claim, string userId)
        //{
        //    string responseClaimId = "";

        //    try
        //    {
        //        string jsonClaim = new JavaScriptSerializer().Serialize(claim);
        //        claim.UserId = userId;
        //        var dataString = JsonConvert.SerializeObject(claim);

        //        using (var client = new WebClient())
        //        {
        //            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
        //            string response = client.UploadString(new Uri(ConfigurationManager.AppSettings["apiurl"] + updateClaimNotificationApiGet1), "POST", dataString);
        //            return bool.Parse(response);
        //        }

        //        return true;

        //    }
        //    catch (Exception e)
        //    {
        //        return false;
        //        throw e;
        //    }


        //}

        public async Task <bool> TeamUpdateClaimNotification(ClaimGeneral claim, string userId)
        {
            string responseClaimId = "";

            try
            {
                string jsonClaim = new JavaScriptSerializer().Serialize(claim);
                claim.UserId = userId;
                var dataString = JsonConvert.SerializeObject(claim);

                using (var client = new HttpClient())
                {
                    using (var formData = new MultipartFormDataContent())
                    {
                        //client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                        //string response = client.UploadString(new Uri(ConfigurationManager.AppSettings["apiurl"] + updateClaimNotificationApiGet1), "POST", dataString);
                        //return bool.Parse(response);

                        var jsonString        = JsonConvert.SerializeObject(claim);
                        var jsonString_userId = JsonConvert.SerializeObject(userId);
                        var content           = new StringContent(jsonString, System.Text.Encoding.UTF8, "application/json");
                        var content_userId    = new StringContent(jsonString_userId, System.Text.Encoding.UTF8, "application/json");
                        formData.Add(content, "claim");
                        //formData.Add(content_userId, "userId");


                        var postResult = await client.PostAsync(ConfigurationManager.AppSettings["apiurl"] + updateClaimNotificationApiGet1, formData);

                        string resultContent = await postResult.Content.ReadAsStringAsync();
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }
Пример #4
0
        //public ExecutionResult TeamInsertClaimNotification(ClaimGeneral claim, string userId)
        //{
        //    string responseClaimId = "";
        //    exeReult = new ExecutionResult();
        //    try
        //    {
        //        string jsonClaim = new JavaScriptSerializer().Serialize(claim);
        //        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
        //            ConfigurationManager.AppSettings["apiurl"] + insertClaimNotificationApiGet1 + jsonClaim +
        //            insertClaimNotificationApiGet2 + userId);

        //        claim.UserId = userId;
        //        var dataString = JsonConvert.SerializeObject(claim);

        //        using (var client = new WebClient())
        //        {
        //            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
        //            string response = client.UploadString(new Uri(ConfigurationManager.AppSettings["apiurl"] + insertClaimNotificationApiGet1), "POST", dataString);
        //            responseClaimId = response;
        //        }

        //        exeReult.ResultObject = responseClaimId;
        //        exeReult.IsSuccess = true;
        //        exeReult.IsFailure = false;
        //        return exeReult;

        //    }
        //    catch (Exception e)
        //    {
        //        exeReult.IsFailure = true;
        //        exeReult.IsSuccess = false;
        //        throw e;
        //    }


        //}


        public async Task <ExecutionResult> TeamInsertClaimNotification(ClaimGeneral claim, string userId, IEnumerable <HttpPostedFileBase> upfiles)
        {
            string responseClaimId = "";

            exeReult = new ExecutionResult();
            try
            {
                string         jsonClaim = new JavaScriptSerializer().Serialize(claim);
                HttpWebRequest request   = (HttpWebRequest)WebRequest.Create(
                    ConfigurationManager.AppSettings["apiurl"] + insertClaimNotificationApiGet1 + jsonClaim +
                    insertClaimNotificationApiGet2 + userId);

                claim.UserId = userId;
                var dataString = JsonConvert.SerializeObject(claim);


                //using (var client = new WebClient())
                //{
                //    client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                //    string response = client.UploadString(new Uri(ConfigurationManager.AppSettings["apiurl"] + insertClaimNotificationApiGet1), "POST", dataString);
                //    responseClaimId = response;
                //}


                using (var client = new HttpClient())
                {
                    using (var formData = new MultipartFormDataContent())
                    {
                        //client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                        //string response = client.UploadString(new Uri(ConfigurationManager.AppSettings["apiurl"] + updateClaimNotificationApiGet1), "POST", dataString);
                        //return bool.Parse(response);

                        var jsonString        = JsonConvert.SerializeObject(claim);
                        var jsonString_userId = JsonConvert.SerializeObject(userId);
                        var content           = new StringContent(jsonString, System.Text.Encoding.UTF8, "application/json");
                        var content_userId    = new StringContent(jsonString_userId, System.Text.Encoding.UTF8, "application/json");

                        formData.Add(content, "claim");

                        if (upfiles != null)
                        {
                            foreach (HttpPostedFileBase item in upfiles)
                            {
                                if (item != null)
                                {
                                    //formData.Add(new StreamContent(item.InputStream), "Attachment", item.FileName);
                                    formData.Add(CreateFileContent(item.InputStream, item.FileName, item.ContentType));
                                }
                            }
                        }

                        var postResult = await client.PostAsync(ConfigurationManager.AppSettings["apiurl"] + insertClaimNotificationApiGet1, formData);

                        string resultContent = await postResult.Content.ReadAsStringAsync();
                    }
                }


                exeReult.ResultObject = responseClaimId;
                exeReult.IsSuccess    = true;
                exeReult.IsFailure    = false;
                return(exeReult);
            }
            catch (Exception e)
            {
                exeReult.IsFailure = true;
                exeReult.IsSuccess = false;
                throw e;
            }
        }