Exemplo n.º 1
0
        public ActionResult DeleteThroughPut(long id)
        {
            var gVal = new GenericValidator();

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Invalid selection";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                var delStatus = new ThroughPutServices().DeleteThroughPut(id);
                if (delStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Docment could not be deleted. Please try again later.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "ThroughPut Information was successfully deleted";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public ActionResult GetThroughPut(long applicationId)
        {
            try
            {
                var throughPut = new ThroughPutServices().GetThroughPut(applicationId);
                if (throughPut == null || throughPut.Id < 1)
                {
                    return(Json(new ThroughPutObject(), JsonRequestBehavior.AllowGet));
                }

                Session["_throughPut"] = throughPut;

                return(Json(throughPut, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new ThroughPutObject(), JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 3
0
        public ActionResult AddThroughPutByDepotOwner(ThroughPutObject throughPut)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPut == null)
                {
                    gVal.Error = "Invalid process call.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPut.Quantity < 1)
                {
                    gVal.Error = "Please provide Quantity.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(throughPut.TempPath))
                {
                    gVal.Error = "Document processing failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var path = MoveFile(importerInfo.Id, throughPut.TempPath);
                if (string.IsNullOrEmpty(path))
                {
                    gVal.Error = "Document processing failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var ip  = ClientIpHelper.GetClientIpAddress(Request);
                var doc = new DocumentObject
                {
                    ImporterId     = importerInfo.Id,
                    DateUploaded   = DateTime.Now,
                    UploadedById   = importerInfo.UserProfileObject.Id,
                    DocumentPath   = path,
                    DocumentTypeId = (int)SpecialDocsEnum.Throughput_agreement,
                    Status         = (int)AppStatus.Pending,
                    IpAddress      = ip
                };

                throughPut.DocumentObject = doc;
                throughPut.IPAddress      = ip;
                var docStatus = new ThroughPutServices().AddThroughPut(throughPut);
                if (docStatus < 1)
                {
                    gVal.Error = "Process failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = docStatus;
                gVal.Path  = path.Replace("~", string.Empty);
                gVal.Error = "Throughput information was successfully processed.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }

            catch (Exception)
            {
                gVal.Error = "ThroughPut processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 4
0
        public ActionResult EditThroughPut(HttpPostedFileBase file, long throughPutId, long documentId, double quantity)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPutId < 1 || quantity < 1)
                {
                    gVal.Error = "Invalid process call.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var doc = new DocumentServices().GetDocument(documentId);
                if (doc.DocumentId < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Document could not be processed. Please try again.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var ip   = ClientIpHelper.GetClientIpAddress(Request);
                var path = "";
                if (file != null && file.ContentLength > 0)
                {
                    path = SaveFile2(doc.DocumentPath, file, importerInfo.Id);
                    if (string.IsNullOrEmpty(path))
                    {
                        gVal.Code  = -1;
                        gVal.Error = "Document Could not be processed.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    doc.DocumentPath = path;
                    doc.UploadedById = importerInfo.UserProfileObject.Id;
                    doc.IpAddress    = ip;
                    doc.Status       = (int)AppStatus.Pending;
                    doc.DateUploaded = DateTime.Now;
                    doc.IpAddress    = ip;
                }

                var throughPut = new ThroughPutObject {
                    DocumentObject = doc, IPAddress = ip, Id = throughPutId, Quantity = quantity
                };

                var docStatus = new ThroughPutServices().UpdateThroughPut(throughPut);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "ThroughPut information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code              = docStatus;
                gVal.Error             = path;
                Session["_throughPut"] = null;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "ThroughPut information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 5
0
        public ActionResult AddThroughPutByApplicant(HttpPostedFileBase file, long throughPutId, double quantity)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPutId < 1 || quantity < 1)
                {
                    gVal.Error = "Invalid process call.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }


                var path = SaveFile2("", file, importerInfo.Id);

                if (string.IsNullOrEmpty(path))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Document information Could not be saved.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var ip  = ClientIpHelper.GetClientIpAddress(Request);
                var doc = new DocumentObject
                {
                    DateUploaded   = DateTime.Now,
                    UploadedById   = importerInfo.UserProfileObject.Id,
                    DocumentPath   = path,
                    DocumentTypeId = (int)SpecialDocsEnum.Throughput_agreement,
                    Status         = (int)AppStatus.Pending,
                    ImporterId     = importerInfo.Id,
                    IpAddress      = ip
                };

                var throughPut = new ThroughPutObject {
                    DocumentObject = doc, IPAddress = ip, Id = throughPutId, Quantity = quantity
                };

                var docStatus = new ThroughPutServices().AddThroughPut(throughPut);
                if (docStatus < 1)
                {
                    gVal.Error = "Process failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = docStatus;
                gVal.Error = path;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }

            catch (Exception)
            {
                gVal.Error = "ThroughPut processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }