Esempio n. 1
0
        // GET: /JobDetails/
        public ActionResult Index(string id = "", string marketguid = "", string jobindexguid = "")
        {
            Logger.Debug("Inside People Controller- Create");
            try
            {
                if (Session["OrganizationGUID"] != null)
                {
                    if (!string.IsNullOrEmpty(jobindexguid))
                    {
                        if (!string.IsNullOrEmpty(id))
                        {
                            TempData["TabName"] = id;
                        }
                        else
                        {
                            TempData["TabName"] = "Details";
                        }
                        DropdownValues();
                        Job _job = _IJobRepository.GetJobByID(new Guid(jobindexguid));

                        JobModel job = new JobModel();
                        job.JobIndexGUID = _job.JobGUID;
                        //   job.JobLogicalID = _IJobSchemaRepository.GetJobFormIDfromJobForm(_job.JobForm.ToString());
                        job.JobReferenceNo = _job.JobReferenceNo;
                        job.JobName        = _job.JobName;
                        if (_job.CustomerGUID != null && !string.IsNullOrEmpty(_job.CustomerGUID.ToString()))
                        {
                            job.CustGUID = new Guid(_job.CustomerGUID.ToString());
                        }
                        else
                        {
                            job.CustGUID = Guid.Empty;
                        }
                        job.IsScheduled = _job.IsSecheduled == true ? "true" : "false";

                        double duration;
                        if (double.TryParse(_job.EstimatedDuration.ToString(), out duration))
                        {
                            TimeSpan time = new TimeSpan();
                            time = TimeSpan.FromSeconds(duration);
                            //timeformat = time.Hours + " : " + time.Minutes + " : " + time.Seconds;
                            job.Duration          = time.Hours + " : " + time.Minutes;
                            job.EstimatedDuration = duration;
                            //job.EstimatedDuration = duration / 3600;
                        }
                        else
                        {
                            job.EstimatedDuration = 0;
                        }
                        job.PreferredStartTime = _job.PreferedStartTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(_job.PreferedStartTime, Session["TimeZoneID"].ToString()) : _job.PreferedStartTime.ToString() : "";

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


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

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

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

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

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

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


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

                        //job.PreferredEndTime = Convert.ToDateTime(_job.PreferedEndTime).ToString("yyyy/MM/dd HH:mm");

                        if (_job.RegionGUID != null)
                        {
                            job.RegionCode = new Guid(_job.RegionGUID.ToString());
                        }
                        else
                        {
                            job.RegionCode = Guid.Empty;
                        }
                        if (_job.TerritoryGUID != null)
                        {
                            job.TerritoryCode = new Guid(_job.TerritoryGUID.ToString());
                        }
                        else
                        {
                            job.TerritoryCode = Guid.Empty;
                        }
                        if (_job.CustomerStopGUID != null && !string.IsNullOrEmpty(_job.CustomerStopGUID.ToString()))
                        {
                            job.StopsGUID = new Guid(_job.CustomerStopGUID.ToString());
                        }
                        else
                        {
                            job.StopsGUID = Guid.Empty;
                        }
                        job.CustomerName = job.CustGUID != Guid.Empty ? _IJobRepository.GetCustomerName(job.CustGUID) : "";
                        job.CreateDate   = _job.CreateDate;
                        int StatusCode;;
                        if (int.TryParse(_job.StatusCode.ToString(), out StatusCode))
                        {
                            job.Status = StatusCode;
                        }
                        else
                        {
                            job.Status = 0;
                        }

                        var placeList = new PlaceViewModel();
                        placeList.PlaceList = new List <PlaceModel>();
                        var appPlace = new List <Place>();

                        appPlace = _IPlaceRepository.GetPlaceByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList();

                        placeList.PlaceList.Add(new PlaceModel
                        {
                            PlaceGUID        = Guid.Empty.ToString(),
                            PlaceName        = "All",
                            UserGUID         = "",
                            OrganizationGUID = "",
                        });

                        foreach (var place in appPlace.ToList())
                        {
                            placeList.PlaceList.Add(new PlaceModel
                            {
                                PlaceGUID        = place.PlaceGUID.ToString(),
                                PlaceID          = place.PlaceID,
                                PlaceName        = place.PlaceName,
                                UserGUID         = place.UserGUID.ToString(),
                                OrganizationGUID = place.OrganizationGUID.ToString(),
                            });
                        }

                        var marketList = new MarketViewModel();
                        marketList.MarketList = new List <MarketModel>();
                        var appMarket = new List <Market>();
                        if (string.IsNullOrEmpty(marketguid) || Guid.Empty == new Guid(marketguid))
                        {
                            // if (Session["UserType"].ToString() == "ENT_A")
                            {
                                appMarket = _IMarketRepository.GetMarketByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString()), 1).ToList();
                            }
                            //else
                            //{
                            //    appMarket = _IMarketRepository.GetMarketByUserGUID(new Guid(Session["UserGUID"].ToString()), 1).ToList();
                            //}
                            if (!string.IsNullOrEmpty(marketguid) && Guid.Empty == new Guid(marketguid))
                            {
                                ViewBag.PlaceGUID = Guid.Empty.ToString();
                            }
                        }
                        else
                        {
                            appMarket         = _IMarketRepository.GetMarketByOwnerGUID(new Guid(marketguid)).ToList();
                            ViewBag.PlaceGUID = marketguid;
                        }
                        foreach (var market in appMarket.ToList())
                        {
                            marketList.MarketList.Add(new MarketModel
                            {
                                MarketGUID         = market.MarketGUID.ToString(),
                                UserGUID           = market.UserGUID.ToString(),
                                OrganizationGUID   = market.OrganizationGUID.ToString(),
                                OwnerGUID          = market.OwnerGUID.ToString(),
                                MarketName         = market.MarketName,
                                MarketPhone        = market.MarketPhone,
                                PrimaryContactGUID = market.PrimaryContactGUID.ToString(),
                                FirstName          = market.FirstName,
                                LastName           = market.LastName,
                                MobilePhone        = market.MobilePhone,
                                HomePhone          = market.HomePhone,
                                Emails             = market.Emails,
                                AddressLine1       = market.AddressLine1,
                                AddressLine2       = market.AddressLine2,
                                City          = market.City,
                                State         = market.State,
                                Country       = market.Country,
                                ZipCode       = market.ZipCode,
                                RegionGUID    = market.RegionGUID != null ? market.RegionGUID.ToString() : Guid.Empty.ToString(),
                                TerritoryGUID = market.TerritoryGUID != null ? market.TerritoryGUID.ToString() : Guid.Empty.ToString(),
                                RegionName    = market.RegionGUID != null ? _IRegionRepository.GetRegionNameByRegionGUID(new Guid(market.RegionGUID.ToString())) : "",
                                TerritoryName = market.TerritoryGUID != null ? _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(market.TerritoryGUID.ToString())) : "",
                            });
                        }
                        List <JobProgressViewModel> pJobProgressViewModel = new List <JobProgressViewModel>();
                        pJobProgressViewModel = getJobProgress(jobindexguid);
                        var viewModel = new JobViewModel();
                        viewModel.Place           = placeList.PlaceList;
                        viewModel.Market          = marketList.MarketList;
                        viewModel.JobModel        = job;
                        viewModel.JobProgressList = pJobProgressViewModel;
                        return(View(viewModel));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "JobDetails", new { id = "Details" }));
                    }
                }
                else
                {
                    return(RedirectToAction("SessionTimeOut", "User"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return(RedirectToAction("Login", "User"));
            }
        }
Esempio n. 2
0
        //
        // GET: /ServicePoint/
        public ActionResult Index(string id = "", string territoryguid = "")
        {
            Logger.Debug("Inside People Controller- Index");
            try
            {
                if (Session["OrganizationGUID"] != null)
                {
                    DropdownValues();
                    var regionList = new RegionViewModel();
                    regionList.Region = new List <RegionModel>();

                    var appRegion = _IRegionRepository.GetRegionByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList();

                    regionList.Region.Add(new RegionModel {
                        Name = "All Regions", RegionGUID = "", Description = "", OrganizationGUID = ""
                    });
                    foreach (var region in appRegion.ToList())
                    {
                        regionList.Region.Add(new RegionModel {
                            Name = region.Name, RegionGUID = region.RegionGUID.ToString(), Description = region.Description, OrganizationGUID = region.OrganizationGUID != null ? region.OrganizationGUID.ToString() : Guid.Empty.ToString()
                        });
                    }

                    var territoryList = new TerritoryViewModel();
                    territoryList.Territory = new List <TerritoryModel>();
                    var appTerritory = new List <Territory>();
                    if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString())
                    {
                        appTerritory = _ITerritoryRepository.GetTerritoryByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList();
                    }
                    else
                    {
                        appTerritory = _ITerritoryRepository.GetTerritoryByRegionGUID(new Guid(id)).ToList();
                    }
                    territoryList.Territory.Add(new TerritoryModel {
                        Name = "All Territories", TerritoryGUID = "", RegionGUID = "", Description = "", OrganizationGUID = ""
                    });
                    foreach (var territory in appTerritory.ToList())
                    {
                        territoryList.Territory.Add(new TerritoryModel {
                            Name = territory.Name, RegionGUID = territory.RegionGUID != null ? territory.RegionGUID.ToString() : Guid.Empty.ToString(), TerritoryGUID = territory.TerritoryGUID.ToString(), Description = territory.Description, OrganizationGUID = territory.OrganizationGUID != null ? territory.OrganizationGUID.ToString() : Guid.Empty.ToString()
                        });
                    }

                    var marketList = new ServicePointViewModel();
                    marketList.MarketList = new List <ServicePointModel>();
                    var appMarket = new List <Market>();
                    if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(territoryguid))
                    {
                        // if (Session["UserType"].ToString() == "ENT_A")
                        {
                            appMarket = _IMarketRepository.GetMarketByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString()), 0).ToList();
                        }
                    }
                    else if (!string.IsNullOrEmpty(id) && string.IsNullOrEmpty(territoryguid))
                    {
                        appMarket             = _IMarketRepository.GetMarketByRegionGUID(new Guid(id), 0).ToList();
                        ViewBag.TerritoryGUID = id;
                    }
                    else if (!string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(territoryguid))
                    {
                        appMarket             = _IMarketRepository.GetMarketByRegionGUIDandTerritoryGUID(new Guid(territoryguid), new Guid(id), 0).ToList();
                        ViewBag.RegionGUID    = territoryguid;
                        ViewBag.TerritoryGUID = id;
                    }
                    foreach (var market in appMarket.ToList())
                    {
                        marketList.MarketList.Add(new ServicePointModel
                        {
                            MarketGUID         = market.MarketGUID.ToString(),
                            UserGUID           = market.UserGUID.ToString(),
                            OrganizationGUID   = market.OrganizationGUID.ToString(),
                            OwnerGUID          = market.OwnerGUID.ToString(),
                            MarketName         = market.MarketName,
                            MarketPhone        = market.MarketPhone,
                            PrimaryContactGUID = market.PrimaryContactGUID.ToString(),
                            FirstName          = market.FirstName,
                            LastName           = market.LastName,
                            MobilePhone        = market.MobilePhone,
                            HomePhone          = market.HomePhone,
                            Emails             = market.Emails,
                            AddressLine1       = market.AddressLine1,
                            AddressLine2       = market.AddressLine2,
                            City          = market.City,
                            State         = market.State,
                            Country       = market.Country,
                            ZipCode       = market.ZipCode,
                            RegionGUID    = market.RegionGUID.ToString(),
                            TerritoryGUID = market.TerritoryGUID.ToString(),
                            RegionName    = market.RegionGUID != null ? _IRegionRepository.GetRegionNameByRegionGUID(new Guid(market.RegionGUID.ToString())) : "",
                            TerritoryName = market.TerritoryGUID != null ? _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(market.TerritoryGUID.ToString())) : "",
                        });
                    }

                    var viewModel = new ServicePointViewModel();
                    viewModel.RegionModel    = regionList.Region.AsEnumerable();
                    viewModel.TerritoryModel = territoryList.Territory.AsEnumerable();
                    viewModel.MarketModel    = marketList.MarketList.AsEnumerable();

                    return(View(viewModel));
                }
                else
                {
                    return(RedirectToAction("SessionTimeOut", "User"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return(RedirectToAction("Login", "User"));
            }
        }