Exemplo n.º 1
0
        public IHttpActionResult EditPO(POs po)
        {
            if (po == null)
            {
                return(BadRequest("PO object is not present the request body"));
            }
            try
            {
                //po.CreatedDate = DateTime.Now;
                //po.IsActive = true;
                //po.POClassificationId = 1;
                var original = pOsService.GetPO(po.PoId);
                po.CreatedDate        = original.CreatedDate;
                po.POClassificationId = 1;
                pOsService.EditPO(po);

                var POs  = pOsService.GetPOs();
                var html = Helpers.RenderPartial("~/Views/Shared/Partial/POs/POsList.cshtml", POs);
                return(Ok(html));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 2
0
        private string GetCompanyNameByPO(string PONumber)
        {
            string companyname = "";

            if (!string.IsNullOrEmpty(PONumber))
            {
                POs lponumber = _IPORepository.GetPObyPoNumber(PONumber);
                if (lponumber != null)
                {
                    companyname = GetCompanyName(lponumber.PlaceID, lponumber.OrganizationGUID != null ? new Guid(lponumber.OrganizationGUID.ToString()) : Guid.Empty);
                }
                else
                {
                    companyname = "";
                }
            }
            return(companyname);
        }
Exemplo n.º 3
0
        public void EditPO(POs PO)
        {
            var original = purchaseOrderRepository.GetById(p => p.PoId == PO.PoId);

            purchaseOrderRepository.Update(original, PO.AutoMapObject <POs, DB.POs>());
        }
Exemplo n.º 4
0
        public POs CreatePO(POs PO)
        {
            var dbPO = purchaseOrderRepository.Insert(PO.AutoMapObject <POs, DB.POs>());

            return(dbPO.AutoMapObject <DB.POs, POs>());
        }
Exemplo n.º 5
0
 public POsAdapter(POs from)
 {
 }
Exemplo n.º 6
0
        public ActionResult Index(string customerid = "", string selection = "", string RowCount = "", int page = 1, string search = "")
        {
            Logger.Debug("Inside Job Controller- Index");
            try
            {
                int totalPage   = 0;
                int totalRecord = 0;
                int pCount      = 0;
                if (Session["OrganizationGUID"] != null)
                {
                    if (!string.IsNullOrEmpty(RowCount))
                    {
                        int.TryParse(RowCount, out pCount);
                        pageCountList(pCount);
                    }
                    else
                    {
                        pageCountList(pCount);
                    }


                    var poList = new POViewLists();
                    poList.POViewList = new List <POView>();
                    var poGroup = new List <POs>();
                    POs lpo     = new POs();
                    if (!string.IsNullOrEmpty(customerid))
                    {
                        Place _place = _IPlaceRepository.GetPlaceByID(new Guid(customerid));
                        if (_place != null)
                        {
                            poGroup = _IPORepository.GetPOListByPlaceID(new Guid(Session["OrganizationGUID"].ToString()), _place.PlaceID).ToList();
                        }
                    }
                    else
                    {
                        poGroup = _IPORepository.GetPOList(new Guid(Session["OrganizationGUID"].ToString())).ToList();
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append("<div class='actions'>");
                    sb.Append("<div class='btn-group'>");
                    if (!string.IsNullOrEmpty(customerid))
                    {
                        sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> " + _IPlaceRepository.GetPlaceByID(new Guid(customerid)).PlaceName + " <i class='icon-angle-down'></i></a>");
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(selection) && selection == "All")
                        {
                            sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> All <i class='icon-angle-down'></i></a>");
                        }
                        else
                        {
                            sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> Select Client <i class='icon-angle-down'></i></a>");
                        }
                    }
                    sb.Append("<ul id='ulworkgroup' style='height:100px;overflow-y:scroll' class='dropdown-menu pull-right'>");
                    if (string.IsNullOrEmpty(selection) || selection != "All")
                    {
                        sb.Append("<li><a href=" + Url.Action("Index", "PO", new { selection = "All" }) + ">All</a></li>");
                    }
                    List <Place> placeList = _IPlaceRepository.GetPlaceByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList();
                    if (placeList != null)
                    {
                        foreach (Place item in placeList)
                        {
                            sb.Append("<li><a href=" + Url.Action("Index", "PO", new { customerid = item.PlaceGUID.ToString() }) + " data-groupguid=" + item.PlaceGUID + ">" + item.PlaceName + "</a></li>");
                        }
                    }
                    sb.Append("</ul>");
                    sb.Append("</div>");
                    sb.Append("</div>");
                    ViewBag.CustomerList = sb.ToString();
                    if (poGroup != null && poGroup.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(search))
                        {
                            search  = search.ToLower();
                            poGroup = poGroup.Where(x => (x.PlaceID != null ? _IPlaceRepository.GetPlaceByID(x.PlaceID, new Guid(x.OrganizationGUID.ToString())).PlaceName.ToLower() : "").Contains(search) ||
                                                    (!String.IsNullOrEmpty(x.PONumber) && GetJobName(x.PONumber).ToLower().Contains(search)) ||
                                                    (!String.IsNullOrEmpty(x.PONumber) && x.PONumber.ToLower().Contains(search)) ||
                                                    (!String.IsNullOrEmpty(x.MarketID) && x.MarketID.ToLower().Contains(search)) ||
                                                    (!String.IsNullOrEmpty(x.InstallerName) && x.InstallerName.ToLower().Contains(search)) ||
                                                    (!String.IsNullOrEmpty(x.POCustomerName) && x.POCustomerName.ToLower().Contains(search)) ||
                                                    (!String.IsNullOrEmpty(x.POCustomerPhone) && x.POCustomerPhone.ToLower().Contains(search))
                                                    ).ToList();


                            poList.POViewList = poList.POViewList.Where(
                                p => (p.PlaceName.ToLower().StartsWith(search)) ||
                                (p.PONumber.ToLower().StartsWith(search)) ||
                                (p.MarketID.ToLower().StartsWith(search)) ||
                                (p.InstallerName.ToLower().StartsWith(search)) ||
                                (p.POCustomerName.ToLower().StartsWith(search)) ||
                                (p.POCustomerPhone.ToLower().StartsWith(search))).ToList();
                        }

                        totalRecord = poGroup.ToList().Count;
                        totalPage   = (totalRecord / (int)ViewBag.pageCountValue) + ((totalRecord % (int)ViewBag.pageCountValue) > 0 ? 1 : 0);

                        ViewBag.TotalRows = totalRecord;

                        poGroup = poGroup.OrderBy(a => a.OrganizationGUID).Skip(((page - 1) * (int)ViewBag.pageCountValue)).Take((int)ViewBag.pageCountValue).ToList();


                        foreach (var pos in poGroup.ToList())
                        {
                            POView Pos = new POView();
                            Pos.POGUID           = pos.POGUID;
                            Pos.OrganizationGUID = pos.OrganizationGUID;
                            Pos.RegionGUID       = pos.RegionGUID;
                            Pos.TerritoryGUID    = pos.TerritoryGUID;
                            Pos.PONumber         = pos.PONumber;
                            Pos.RegionName       = pos.RegionGUID != null && pos.RegionGUID != Guid.Empty ? _IRegionRepository.GetRegionNameByRegionGUID(new Guid(pos.RegionGUID.ToString())) : "";
                            Pos.TerritoryName    = pos.TerritoryGUID != null && pos.TerritoryGUID != Guid.Empty ? _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(pos.TerritoryGUID.ToString())) : "";
                            Pos.InstallerName    = pos.InstallerName;
                            Pos.POCustomerName   = pos.POCustomerName;
                            Pos.POCustomerPhone  = pos.POCustomerPhone;
                            Pos.PoCustomerMobile = pos.POCustomerMobile;
                            if (!string.IsNullOrEmpty(pos.MarketID) && !string.IsNullOrEmpty(pos.PlaceID))
                            {
                                Market _market = _IMarketRepository.GetMarketByCustomerID(new Guid(pos.OrganizationGUID.ToString()), pos.PlaceID, pos.MarketID);
                                if (_market != null)
                                {
                                    Pos.StoreName = _market.MarketName;
                                }
                                else
                                {
                                    Pos.StoreName = "";
                                }
                            }
                            else
                            {
                                Pos.StoreName = "";
                            }
                            if (!string.IsNullOrEmpty(pos.PlaceID))
                            {
                                Place _place = _IPlaceRepository.GetPlaceByID(pos.PlaceID, new Guid(pos.OrganizationGUID.ToString()));
                                if (_place != null)
                                {
                                    Pos.PlaceName = _place.PlaceName;
                                }
                                else
                                {
                                    Pos.PlaceName = "";
                                }
                            }
                            else
                            {
                                Pos.PlaceName = "";
                            }
                            Pos.EmailID            = !string.IsNullOrEmpty(pos.MarketID) ? GetEmails(pos.OrganizationGUID, pos.MarketID, pos.PlaceID) : "";
                            Pos.JobName            = GetJobName(pos.PONumber);
                            Pos.Status             = pos.Status;
                            Pos.Description        = pos.Description;
                            Pos.PlaceID            = pos.PlaceID;
                            Pos.LocationType       = pos.LocationType;
                            Pos.MarketID           = pos.MarketID;
                            Pos.EndCustomerAddress = pos.EndCustomerAddress;
                            Pos.EndCustomerName    = pos.EndCustomerName;
                            Pos.EndCustomerPhone   = pos.EndCustomerPhone;
                            Pos.WorkerName         = pos.WorkerName;
                            Pos.CustomBooleanValue = pos.CustomBooleanValue;
                            Pos.JobClass           = pos.JobClass;
                            Pos.OrderDate          = pos.OrderDate.ToString();
                            Pos.PreferredDateTime  = pos.PreferredDateTime.ToString();
                            Pos.EstimatedCost      = pos.EstimatedCost;
                            Pos.CreateDate         = pos.CreateDate.ToString();
                            Pos.CreateBy           = pos.CreateBy;
                            Pos.LastModifiedDate   = pos.LastModifiedDate.ToString();
                            Pos.LastModifiedBy     = pos.LastModifiedBy;
                            poList.POViewList.Add(Pos);
                        }
                    }

                    return(View(poList));
                }
                else
                {
                    return(RedirectToAction("SessionTimeOut", "User"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return(RedirectToAction("../User/Login"));
            }
        }
Exemplo n.º 7
0
        //
        // GET: /JobStatus/
        public ActionResult Index(string FromDate = "", string ToDate = "", string regionguid = "", string territoryguid = "", string jobindexguid = "", string Date = "", string selection = "", string ponumber = "")
        {
            Logger.Debug("Inside AssignJob Controller- Index");
            try
            {
                if (Session["OrganizationGUID"] != null)
                {
                    if (!string.IsNullOrEmpty(Date))
                    {
                        ViewBag.DateValue = HttpUtility.HtmlDecode(Date);
                    }
                    var jobStatus = new JobStatusViewModel();
                    jobStatus.JobStatusModel = new List <JobStatusModel>();
                    var jobGroup = new List <Job>();
                    //Job ljob = new Job();

                    OrganizationUsersMap pOrganizationUsersMap = _IUserRepository.GetUserByID(new Guid(Session["UserGUID"].ToString()));
                    Logger.Debug("USerGUID:" + Session["UserGUID"].ToString());
                    if (pOrganizationUsersMap != null)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<div class='actions'>");
                        sb.Append("<div class='btn-group'>");
                        if (!string.IsNullOrEmpty(territoryguid))
                        {
                            Logger.Debug("Inside TerritoryGUID" + territoryguid.ToString());
                            sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> " + _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(territoryguid)) + " <i class='icon-angle-down'></i></a>");
                        }
                        else
                        {
                            if (Session["UserType"] != null && Session["UserType"].ToString() != "ENT_U")
                            {
                                if (!string.IsNullOrEmpty(selection) && selection == "All")
                                {
                                    sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> All <i class='icon-angle-down'></i></a>");
                                }
                                else
                                {
                                    sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> Select Market <i class='icon-angle-down'></i></a>");
                                }
                            }
                            else if (pOrganizationUsersMap != null)
                            {
                                sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> " + _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(pOrganizationUsersMap.TerritoryGUID.ToString())) + " <i class='icon-angle-down'></i></a>");
                            }
                        }
                        sb.Append("<ul id='ulworkgroup' class='dropdown-menu pull-right'>");

                        if (Session["UserType"] != null && Session["UserType"].ToString() != "ENT_U" && pOrganizationUsersMap != null)
                        {
                            if (string.IsNullOrEmpty(selection) || selection != "All")
                            {
                                sb.Append("<li><a href=" + Url.Action("Index", "JobStatus", new { selection = "All" }) + ">All</a></li>");
                            }
                            List <Territory> TerritoryList = new List <Territory>();
                            if (Session["UserType"].ToString() == "ENT_A")
                            {
                                Logger.Debug("Inside OrganizationGUID" + pOrganizationUsersMap.OrganizationGUID.ToString());
                                TerritoryList = _ITerritoryRepository.GetTerritoryByOrganizationGUID(new Guid(pOrganizationUsersMap.OrganizationGUID.ToString())).ToList();
                            }
                            else
                            {
                                if (pOrganizationUsersMap.RegionGUID != null)
                                {
                                    Logger.Debug("Inside RegionGUID" + pOrganizationUsersMap.RegionGUID.ToString());
                                    TerritoryList = _ITerritoryRepository.GetTerritoryByRegionGUID(new Guid(pOrganizationUsersMap.RegionGUID.ToString())).ToList();
                                }
                            }
                            if (TerritoryList != null && TerritoryList.Count > 0)
                            {
                                foreach (Territory item in TerritoryList)
                                {
                                    sb.Append("<li><a href=" + Url.Action("Index", "JobStatus", new { territoryguid = item.TerritoryGUID.ToString(), regionguid = item.RegionGUID.ToString() }) + " data-groupguid=" + item.TerritoryGUID + ">" + item.Name + "</a></li>");
                                    Logger.Debug("Inside Territory foreach");
                                }
                            }
                        }
                        sb.Append("</ul>");
                        sb.Append("</div>");
                        sb.Append("</div>");

                        ViewBag.RegionList = sb.ToString();
                        Job mjob = new Job();
                        if (!string.IsNullOrEmpty(ponumber))
                        {
                            mjob.PONumber        = ponumber;
                            TempData["PoNumber"] = ponumber;
                        }
                        if (!string.IsNullOrEmpty(FromDate) && !string.IsNullOrEmpty(ToDate))
                        {
                            //ViewBag.FromDate = FromDate;
                            //ViewBag.ToDate = ToDate;
                            if (Session["UserType"] != null && Session["UserType"].ToString() == "ENT_U")
                            {
                                mjob.ActualStartTime = Convert.ToDateTime(FromDate);
                                // mjob.PreferedStartTime = _IUserRepository.GetLocalDateTime(mjob.PreferedStartTime, Session["TimeZoneID"].ToString());
                                mjob.ActualEndTime = Convert.ToDateTime(ToDate);
                                //  mjob.PreferedEndTime = _IUserRepository.GetLocalDateTime(mjob.PreferedEndTime, Session["TimeZoneID"].ToString());
                                mjob.TerritoryGUID    = pOrganizationUsersMap.TerritoryGUID;
                                mjob.RegionGUID       = pOrganizationUsersMap.RegionGUID;
                                mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString());
                                jobGroup = _IJobRepository.GetJobs(mjob);
                            }
                            else
                            {
                                mjob.ActualStartTime = Convert.ToDateTime(FromDate);
                                //   mjob.PreferedStartTime = _IUserRepository.GetLocalDateTime(mjob.PreferedStartTime, Session["TimeZoneID"].ToString());
                                mjob.ActualEndTime = Convert.ToDateTime(ToDate);
                                //    mjob.PreferedEndTime = _IUserRepository.GetLocalDateTime(mjob.PreferedEndTime, Session["TimeZoneID"].ToString());
                                mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString());
                                jobGroup = _IJobRepository.GetJobs(mjob);
                            }
                        }
                        else if (!string.IsNullOrEmpty(regionguid) && !string.IsNullOrEmpty(territoryguid))
                        {
                            mjob.ActualStartTime  = DateTime.Now.AddDays(-29);
                            mjob.ActualEndTime    = DateTime.Now;
                            mjob.RegionGUID       = new Guid(regionguid);
                            mjob.TerritoryGUID    = new Guid(territoryguid);
                            mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString());
                            jobGroup = _IJobRepository.GetJobs(mjob);
                        }
                        else
                        {
                            mjob.ActualStartTime = DateTime.Now.AddDays(-29);
                            mjob.ActualEndTime   = DateTime.Now;
                            if (Session["UserType"] != null && Session["UserType"].ToString() == "ENT_U")
                            {
                                mjob.RegionGUID       = pOrganizationUsersMap.RegionGUID;
                                mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString());
                                jobGroup = _IJobRepository.GetJobs(mjob);
                            }
                            else
                            {
                                mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString());
                                jobGroup = _IJobRepository.GetJobs(mjob);
                            }
                            //if (Session["UserType"] != null && Session["UserType"].ToString() != "ENT_U")
                            //{
                            //    jobGroup = _IJobRepository.GetjobStatusByRegionAndTerritory(new Guid(Session["UserGUID"].ToString())).ToList();
                            //}
                            //else
                            //{
                            //    ljob.AssignedUserGUID = new Guid(Session["UserGUID"].ToString());
                            //    ljob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString());
                            //    ljob.IsDeleted = false;
                            //    jobGroup = _IJobRepository.GetJobStatus(ljob).ToList();
                            //}
                        }

                        if (jobGroup != null && jobGroup.Count > 0)
                        {
                            foreach (var job in jobGroup.ToList())
                            {
                                JobStatusModel js = new JobStatusModel();
                                js.JobName      = job.JobName;
                                js.JobIndexGUID = job.JobGUID.ToString();
                                //  js.JobLogicalID = job.JobFormGUID.ToString();
                                js.UserGUID = job.AssignedUserGUID.ToString();

                                js.PreferredStartTime = job.PreferedStartTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.PreferedStartTime, Session["TimeZoneID"].ToString()) : job.PreferedStartTime.ToString() : "";

                                js.PreferredStartTime = !string.IsNullOrEmpty(js.PreferredStartTime) ? _IUserRepository.GetLocalDateTime(job.PreferedStartTime, Session["TimeZoneID"].ToString()) : "";
                                js.PreferredStartTime = !string.IsNullOrEmpty(js.PreferredStartTime) ? Convert.ToDateTime(js.PreferredStartTime).ToString("MM/dd/yy HH:mm") : "";

                                js.PreferredEndTime = job.PreferedEndTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.PreferedEndTime, Session["TimeZoneID"].ToString()) : job.PreferedEndTime.ToString() : "";

                                js.PreferredEndTime = !string.IsNullOrEmpty(js.PreferredEndTime) ? _IUserRepository.GetLocalDateTime(job.PreferedEndTime, Session["TimeZoneID"].ToString()) : "";
                                js.PreferredEndTime = !string.IsNullOrEmpty(js.PreferredEndTime) ? Convert.ToDateTime(js.PreferredEndTime).ToString("MM/dd/yy HH:mm") : "";

                                js.ActualStartTime = job.ActualStartTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : job.ActualStartTime.ToString() : "";

                                js.ActualStartTime = !string.IsNullOrEmpty(js.ActualStartTime) ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : "";
                                js.ActualStartTime = !string.IsNullOrEmpty(js.ActualStartTime) ? Convert.ToDateTime(js.ActualStartTime).ToString("MM/dd/yy HH:mm") : "";

                                js.ActualEndTime = job.PreferedEndTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.ActualEndTime, Session["TimeZoneID"].ToString()) : job.ActualEndTime.ToString() : "";

                                js.ActualEndTime = !string.IsNullOrEmpty(js.ActualEndTime) ? _IUserRepository.GetLocalDateTime(job.ActualEndTime, Session["TimeZoneID"].ToString()) : "";
                                js.ActualEndTime = !string.IsNullOrEmpty(js.ActualEndTime) ? Convert.ToDateTime(js.ActualEndTime).ToString("MM/dd/yy HH:mm") : "";


                                js.LastModifiedDate = job.PreferedEndTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.LastModifiedDate, Session["TimeZoneID"].ToString()) : job.LastModifiedDate.ToString() : "";

                                js.LastModifiedDate = !string.IsNullOrEmpty(js.LastModifiedDate) ? _IUserRepository.GetLocalDateTime(job.LastModifiedDate, Session["TimeZoneID"].ToString()) : "";
                                js.LastModifiedDate = !string.IsNullOrEmpty(js.LastModifiedDate) ? Convert.ToDateTime(js.LastModifiedDate).ToString("MM/dd/yy HH:mm") : "";



                                //  ActualStartTime = job.ActualStartTime.ToString() != "" ? Convert.ToDateTime(job.ActualStartTime).ToString("yyyy/MM/dd HH:mm") : "",//, Session["TimeZoneID"].ToString()
                                js.EstimatedStartTime = job.ActualStartTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : job.ActualStartTime.ToString() : "";

                                js.EstimatedStartTime = !string.IsNullOrEmpty(js.EstimatedStartTime) ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : "";
                                js.EstimatedStartTime = !string.IsNullOrEmpty(js.EstimatedStartTime) ? Convert.ToDateTime(js.EstimatedStartTime).ToString("MM/dd/yy HH:mm") : "";
                                //js.AssignedTo = _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())) != null ? _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())).UserName : "";
                                js.EstimatedDuration = Convert.ToDouble(job.EstimatedDuration);
                                js.Status            = _IJobRepository.GetStatusName(Convert.ToInt32(job.StatusCode));
                                // js.CustomerName = !string.IsNullOrEmpty(job.CustomerGUID.ToString()) ? GetCompanyName(new Guid(job.CustomerGUID.ToString())) : "";
                                js.CustomerName = job.CustomerGUID != null?GetCompanyName(job.CustomerGUID) : GetCompanyNameByPO(job.PONumber);

                                js.StoreID    = !string.IsNullOrEmpty(job.CustomerGUID.ToString()) ? getStoreID(job.CustomerStopGUID.ToString()) : "";
                                js.PONumber   = job.PONumber;
                                js.statuscode = job.StatusCode != null?Convert.ToInt32(job.StatusCode) : 0;

                                js.RegionGUID = job.RegionGUID != null?job.RegionGUID.ToString() : "";

                                js.TerritoryGUID = job.TerritoryGUID != null?job.TerritoryGUID.ToString() : "";

                                js.SiteAddress = job.ServiceAddress;
                                JobProgress pJobProgress = _IJobRepository.GetJobProgressMismatch(job.JobGUID, js.statuscode);
                                bool        mismatch;
                                if (pJobProgress != null && bool.TryParse(pJobProgress.LocationMismatch.ToString(), out mismatch))
                                {
                                    js.locationmismatch = mismatch;
                                }
                                if (job.StatusCode >= 2 && job.AssignedUserGUID != null)
                                {
                                    js.Email = GetEmails(new Guid(job.AssignedUserGUID.ToString()), pOrganizationUsersMap.OrganizationGUID);
                                    js.AssociateContactNumber = GetContactNumber(new Guid(job.AssignedUserGUID.ToString()), pOrganizationUsersMap.OrganizationGUID);
                                    GlobalUser _globaluser = _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString()));
                                    if (_globaluser != null)
                                    {
                                        js.AssociateName = _globaluser.UserName;
                                        js.AssignedTo    = _globaluser.UserName;
                                    }
                                    else
                                    {
                                        js.AssignedTo    = "";
                                        js.AssociateName = "";
                                    }
                                }
                                else
                                {
                                    js.Email                  = "";
                                    js.AssignedTo             = "";
                                    js.AssociateName          = "";
                                    js.AssociateContactNumber = "";
                                }
                                //js.GroupName = _IJobRepository.GetGroupName(job.GroupCode);



                                if (job.CustomerStopGUID != null && job.CustomerStopGUID != Guid.Empty)
                                {
                                    Market _Market = _IMarketRepository.GetMarketByID(new Guid(job.CustomerStopGUID.ToString()));
                                    if (_Market != null)
                                    {
                                        if (!string.IsNullOrEmpty(_Market.RMUserID))
                                        {
                                            GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.RMUserID, Session["OrganizationGUID"].ToString());
                                            if (_globalUser != null)
                                            {
                                                UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, job.OrganizationGUID);
                                                if (_userprofile != null)
                                                {
                                                    js.RegionalManager = _userprofile.FirstName + " " + _userprofile.LastName;
                                                }
                                                else
                                                {
                                                    js.RegionalManager = "";
                                                }
                                            }
                                        }
                                        else
                                        {
                                            js.RegionalManager = "";
                                        }
                                        if (!string.IsNullOrEmpty(_Market.FMUserID))
                                        {
                                            GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.FMUserID, Session["OrganizationGUID"].ToString());
                                            if (_globalUser != null)
                                            {
                                                UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, pOrganizationUsersMap.OrganizationGUID);
                                                if (_userprofile != null)
                                                {
                                                    js.FieldManager = _userprofile.FirstName + " " + _userprofile.LastName;
                                                }
                                                else
                                                {
                                                    js.FieldManager = "";
                                                }
                                            }
                                        }
                                        else
                                        {
                                            js.FieldManager = "";
                                        }
                                    }
                                    else
                                    {
                                        js.RegionalManager = "";
                                        js.FieldManager    = "";
                                    }
                                }
                                else if (!string.IsNullOrEmpty(job.PONumber))
                                {
                                    POs _po = _IPORepository.GetPObyPoNumber(job.PONumber);
                                    if (_po != null)
                                    {
                                        Market _Market = _IMarketRepository.GetMarketByCustomerID(job.OrganizationGUID, _po.PlaceID, _po.MarketID);
                                        if (_Market != null)
                                        {
                                            if (!string.IsNullOrEmpty(_Market.RMUserID))
                                            {
                                                GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.RMUserID, Session["OrganizationGUID"].ToString());
                                                if (_globalUser != null)
                                                {
                                                    UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, job.OrganizationGUID);
                                                    if (_userprofile != null)
                                                    {
                                                        js.RegionalManager = _userprofile.FirstName + " " + _userprofile.LastName;
                                                    }
                                                    else
                                                    {
                                                        js.RegionalManager = "";
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                js.RegionalManager = "";
                                            }
                                            if (!string.IsNullOrEmpty(_Market.FMUserID))
                                            {
                                                GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.FMUserID, Session["OrganizationGUID"].ToString());
                                                if (_globalUser != null)
                                                {
                                                    UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, job.OrganizationGUID);
                                                    if (_userprofile != null)
                                                    {
                                                        js.FieldManager = _userprofile.FirstName + " " + _userprofile.LastName;
                                                    }
                                                    else
                                                    {
                                                        js.FieldManager = "";
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                js.FieldManager = "";
                                            }
                                        }
                                        else
                                        {
                                            js.RegionalManager = "";
                                            js.FieldManager    = "";
                                        }
                                    }
                                    else
                                    {
                                        js.RegionalManager = "";
                                        js.FieldManager    = "";
                                    }
                                }
                                else
                                {
                                    js.RegionalManager = "";
                                    js.FieldManager    = "";
                                }

                                jobStatus.JobStatusModel.Add(js);
                            }
                        }
                        if (!string.IsNullOrEmpty(regionguid) && !string.IsNullOrEmpty(territoryguid) && !string.IsNullOrEmpty(jobindexguid))
                        {
                            IList <GlobalUser> _GlobalUser = _IGlobalUserRepository.GetGlobalUserByRegionandTerritory(new Guid(regionguid), new Guid(territoryguid)).ToList();
                            jobStatus.GlobalUsers = new List <GlobalUserModel>();
                            foreach (var user in _GlobalUser.ToList())
                            {
                                jobStatus.GlobalUsers.Add(new GlobalUserModel
                                {
                                    UserGUID = user.UserGUID,
                                    UserName = user.UserName
                                });
                            }

                            if (!string.IsNullOrEmpty(jobindexguid))
                            {
                                jobStatus.JobModel              = new JobModel();
                                jobStatus.JobModel.JobName      = _IJobRepository.GetJobByID(new Guid(jobindexguid)).JobName;
                                jobStatus.JobModel.JobIndexGUID = new Guid(jobindexguid);
                            }
                        }
                    }



                    return(View(jobStatus));
                }
                else
                {
                    //TempData["msg"] = "<script>ModalPopupsAlert('Workers-In-Motion','Session Expired');</script>";
                    //return RedirectToAction("../User/Login");
                    return(RedirectToAction("SessionTimeOut", "User"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return(RedirectToAction("Login", "User"));
            }
        }
Exemplo n.º 8
0
        private int InsertPO(POs NewPO)
        {
            //context.POs.Add(NewPO);

            SqlParameter[] Param = new SqlParameter[25];
            Param[0]       = new SqlParameter("@pPOGUID", SqlDbType.UniqueIdentifier);
            Param[0].Value = NewPO.POGUID;
            Param[1]       = new SqlParameter("@pOrganizationGUID", SqlDbType.UniqueIdentifier);
            Param[1].Value = (object)NewPO.OrganizationGUID ?? DBNull.Value;
            Param[2]       = new SqlParameter("@pRegionGUID", SqlDbType.UniqueIdentifier);
            Param[2].Value = (object)NewPO.RegionGUID ?? DBNull.Value;
            Param[3]       = new SqlParameter("@pTerritoryGUID", SqlDbType.UniqueIdentifier);
            Param[3].Value = (object)NewPO.TerritoryGUID ?? DBNull.Value;
            Param[4]       = new SqlParameter("@pPONumber", SqlDbType.NVarChar, 50);
            Param[4].Value = (object)NewPO.PONumber ?? DBNull.Value;
            Param[5]       = new SqlParameter("@pStatus", SqlDbType.SmallInt);
            Param[5].Value = (object)NewPO.Status ?? DBNull.Value;

            Param[6]       = new SqlParameter("@pPlaceID", SqlDbType.NVarChar, 50);
            Param[6].Value = (object)NewPO.PlaceID ?? DBNull.Value;
            //Heroku
            //Param[8] = new SqlParameter("@pLocationType", SqlDbType.SmallInt);
            //Param[8].Value = (object)NewPO.LocationType ?? DBNull.Value;
            Param[7]        = new SqlParameter("@pMarketID", SqlDbType.NVarChar, 50);
            Param[7].Value  = (object)NewPO.MarketID ?? DBNull.Value;
            Param[8]        = new SqlParameter("@pEndCustomerAddress", SqlDbType.NVarChar, -1);
            Param[8].Value  = (object)NewPO.EndCustomerAddress ?? DBNull.Value;
            Param[9]        = new SqlParameter("@pEndCustomerName", SqlDbType.NVarChar, -1);
            Param[9].Value  = (object)NewPO.EndCustomerName ?? DBNull.Value;
            Param[10]       = new SqlParameter("@pEndCustomerPhone", SqlDbType.NVarChar, -1);
            Param[10].Value = (object)NewPO.EndCustomerPhone ?? DBNull.Value;


            Param[11]       = new SqlParameter("@pCreateDate", SqlDbType.DateTime);
            Param[11].Value = (object)NewPO.CreateDate ?? DBNull.Value;
            Param[12]       = new SqlParameter("@pCreateBy", SqlDbType.UniqueIdentifier);
            Param[12].Value = (object)NewPO.CreateBy ?? DBNull.Value;
            Param[13]       = new SqlParameter("@pLastModifiedDate", SqlDbType.DateTime);
            Param[13].Value = (object)NewPO.LastModifiedDate ?? DBNull.Value;
            Param[14]       = new SqlParameter("@pLastModifiedBy", SqlDbType.UniqueIdentifier);
            Param[14].Value = (object)NewPO.LastModifiedBy ?? DBNull.Value;

            Param[15]       = new SqlParameter("@pTerritoryID", SqlDbType.NVarChar, 50);
            Param[15].Value = (object)NewPO.TerritoryID ?? DBNull.Value;

            Param[16]       = new SqlParameter("@pRMUserID", SqlDbType.NVarChar, 50);
            Param[16].Value = (object)NewPO.RMUserID ?? DBNull.Value;
            Param[17]       = new SqlParameter("@pFMUserID", SqlDbType.NVarChar, 50);
            Param[17].Value = (object)NewPO.FMUserID ?? DBNull.Value;
            Param[18]       = new SqlParameter("@pPOJobType", SqlDbType.NVarChar, 50);
            Param[18].Value = (object)NewPO.POJobType ?? DBNull.Value;
            Param[19]       = new SqlParameter("@pPOJobCode", SqlDbType.NVarChar, 50);
            Param[19].Value = (object)NewPO.POJobCode ?? DBNull.Value;
            Param[20]       = new SqlParameter("@pPOJson", SqlDbType.NVarChar, -1);
            Param[20].Value = (object)NewPO.POJson ?? DBNull.Value;
            Param[21]       = new SqlParameter("@pInstallerName", SqlDbType.NVarChar, 50);
            Param[21].Value = (object)NewPO.InstallerName ?? DBNull.Value;
            Param[22]       = new SqlParameter("@pPOCustomerName", SqlDbType.NVarChar, 50);
            Param[22].Value = (object)NewPO.POCustomerName ?? DBNull.Value;
            Param[23]       = new SqlParameter("@pPOCustomerPhone", SqlDbType.NVarChar, 50);
            Param[23].Value = (object)NewPO.POCustomerPhone ?? DBNull.Value;
            Param[24]       = new SqlParameter("@pPOCustomerMobile", SqlDbType.NVarChar, 50);
            Param[24].Value = (object)NewPO.POCustomerMobile ?? DBNull.Value;


            return(context.Database.ExecuteSqlCommand("insert into POs(POGUID,OrganizationGUID,RegionGUID,TerritoryGUID,PONumber,Status,PlaceID"
                                                      + " ,MarketID,EndCustomerAddress,EndCustomerName,EndCustomerPhone"
                                                      + ",CreateDate,CreateBy,LastModifiedDate,LastModifiedBy,TerritoryID,RMUserID,FMUserID,POJobType"
                                                      + ",POJobCode,POJson,InstallerName,POCustomerName,POCustomerPhone,POCustomerMobile)"
                                                      + "values(@pPOGUID,@pOrganizationGUID,@pRegionGUID,@pTerritoryGUID,@pPONumber"
                                                      + ",@pStatus,@pPlaceID,@pMarketID,@pEndCustomerAddress,@pEndCustomerName,@pEndCustomerPhone"
                                                      + ",@pCreateDate,@pCreateBy,@pLastModifiedDate,@pLastModifiedBy,@pTerritoryID"
                                                      + ",@pRMUserID,@pFMUserID,@pPOJobType,@pPOJobCode,@pPOJson,@pInstallerName,@pPOCustomerName,@pPOCustomerPhone,@pPOCustomerMobile)", Param));
        }
Exemplo n.º 9
0
 public int CreatePO(POs NewPO)
 {
     return(InsertPO(NewPO));
     //return Save();
 }
Exemplo n.º 10
0
        public int CreatePO(POs pOs)
        {
            var res = pORepository.Insert(pOs.AutoMapObject <POs, DB.POs>());

            return(res.PoId);
        }