Exemplo n.º 1
0
        public ActionResult Index(Batch batch)
        {
            string LoginUser   = (string)Session["LoginSAPID"];
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string EmployerId  = (string)Session["EMPLOYER_ID"];
            string CompanyName = (string)Session["CompanyName"];

            try
            {
                Employer.Employer employer = new Employer.Employer();

                if (batch.statementOption == "1")
                {
                    if (batch.ContactName2 == null)
                    {
                        batch.ContactName2 = "";
                    }

                    if (batch.ContactAddress1 == null)
                    {
                        batch.ContactAddress1 = "";
                    }

                    if (batch.ContactPhone2 == null)
                    {
                        batch.ContactPhone2 = "";
                    }

                    var batchStatus   = employer.MapDeliverybyEmployer(CompanyName, EmployerId, batch.ContactName, batch.ContactName2, batch.ContactPhone, batch.ContactPhone2, batch.ContactAddress, batch.ContactAddress1, userkey, uid);
                    var statusDetails = batchStatus.Split('~');

                    if (statusDetails[0] != "01")
                    {
                        TempData["bMsg"] = statusDetails[1];
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["bError"] = statusDetails[1];
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    var pins          = string.Join(",", batch.id);
                    var batchStatus   = employer.MapDeliverybyBatch(CompanyName, EmployerId, batch.AddressId, batch.BatchId, pins, userkey, uid);
                    var statusDetails = batchStatus.Split('~');
                    //employer.();

                    if (statusDetails[0] != "01")
                    {
                        TempData["bMsg"] = statusDetails[1];
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["bError"] = statusDetails[1];
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "StatementOptions/Batch", "StatementOptions", "Index", "MapDeliverybyBatch Error", ex.Message.ToString(), 0);
                TempData["bError"] = ex.Message.ToString();
                return(RedirectToAction("Index"));
            }
        }