예제 #1
0
        public Pc1Detail GetAdpDDL(int year, string serial, string sector, string subsector)
        {
            var model = new Pc1Detail();

            try
            {
                //var obj = new tbl_ADP_Serial();
                //if (!string.IsNullOrEmpty(sector))
                //{
                //    if (!string.IsNullOrEmpty(subsector))
                //    {
                //        var subsectorId = Convert.ToInt32(subsector);
                //        var sectorId = Convert.ToInt32(sector);
                //        obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year && x.auto_Sector_id == sectorId && x.auto_SubSector_ID == subsectorId);
                //    }
                //    else
                //    {
                //        var sectorId = Convert.ToInt32(sector);
                //        obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year && x.auto_Sector_id == sectorId);
                //    }

                //}
                //else
                //{
                //    obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year);
                //}

                //if (obj != null)
                //{
                //    model.Serial = obj.auto_adp_serial_id + "";
                //    model.Name = obj.ProjectName;
                //    model.Cost = obj.Allocation + "";
                //    model.SectorId = obj.auto_Sector_id + "";
                //    model.SubsectorId = obj.auto_SubSector_ID + "";
                //    model.DistrictId = obj.Distt_ID + "";
                //    model.DivisionId = obj.Div_ID + "";
                //    model.DepartmentId = obj.auto_Dept_Id + "";
                //    var distIds = db.tbl_AdpBook_multipleDist.Where(x => x.auto_adp_serial_id == obj.auto_adp_serial_id).ToList();
                //    List<int?> termsList = new List<int?>();
                //    foreach (var item in distIds)
                //    {
                //        termsList.Add(item.Distt_ID);
                //    }
                //    model.DistIds = termsList;
                //}
                var obj = new tbl_ADP_Serial();
                if (!string.IsNullOrEmpty(sector))
                {
                    if (!string.IsNullOrEmpty(subsector))
                    {
                        var subsectorId = Convert.ToInt32(subsector);
                        var sectorId    = Convert.ToInt32(sector);
                        obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year && x.auto_Sector_id == sectorId && x.auto_SubSector_ID == subsectorId);
                    }
                    else
                    {
                        var sectorId = Convert.ToInt32(sector);
                        obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year && x.auto_Sector_id == sectorId);
                    }
                }
                else
                {
                    obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year);
                }

                if (obj != null)
                {
                    model.Serial       = obj.auto_adp_serial_id + "";
                    model.Name         = obj.ProjectName;
                    model.Cost         = obj.Allocation + "";
                    model.SectorId     = obj.auto_Sector_id + "";
                    model.SubsectorId  = obj.auto_SubSector_ID + "";
                    model.DistrictId   = obj.Distt_ID + "";
                    model.DivisionId   = obj.Div_ID + "";
                    model.DepartmentId = obj.auto_Dept_Id + "";
                    var         distIds   = db.tbl_AdpBook_multipleDist.Where(x => x.auto_adp_serial_id == obj.auto_adp_serial_id).ToList();
                    List <int?> termsList = new List <int?>();
                    foreach (var item in distIds)
                    {
                        termsList.Add(item.Distt_ID);
                    }
                    model.DistIds = termsList;
                }
                model.RequestStatus = "Ok";
            }
            catch (Exception)
            {
                model.RequestStatus = "Error";
            }

            return(model);
        }
예제 #2
0
        public Pc1Detail GetAdpDetail(int year, string serial, int?sector, int?subsector)
        {
            var model = new Pc1Detail();

            try
            {
                var obj    = new tbl_ADP_Serial();
                var result = db.Rest_Get_Adp_Detail(serial, year, sector, subsector).ToList();
                if (result.Count > 0)
                {
                    var r = result.FirstOrDefault();
                    model.Serial                  = r.auto_adp_serial_id + "";
                    model.Name                    = r.ProjectName;
                    model.Cost                    = r.Allocation + "";
                    model.SectorId                = r.auto_Sector_id + "";
                    model.SubsectorId             = r.auto_SubSector_ID + "";
                    model.DistrictId              = r.Distt_ID + "";
                    model.DivisionId              = r.Div_ID + "";
                    model.DepartmentId            = r.auto_Dept_Id + "";
                    model.yearly_total_allocation = r.yearly_total_allocation + "";
                    model.DistIds                 = result.Select(x => x.Districts).ToList();
                }


                //if (!string.IsNullOrEmpty(sector))
                //{
                //    if (!string.IsNullOrEmpty(subsector))
                //    {
                //        var subsectorId = Convert.ToInt32(subsector);
                //        var sectorId = Convert.ToInt32(sector);
                //        obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year && x.auto_Sector_id == sectorId && x.auto_SubSector_ID == subsectorId);
                //    }
                //    else
                //    {
                //        var sectorId = Convert.ToInt32(sector);
                //        obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year && x.auto_Sector_id == sectorId);
                //    }
                //}
                //else
                //{
                //    obj = db.tbl_ADP_Serial.FirstOrDefault(x => x.serial_no_ADP == serial && x.auto_ADP_id == year);
                //}

                //if (obj != null)
                //{

                //    var distIds = db.tbl_AdpBook_multipleDist.Where(x => x.auto_adp_serial_id == obj.auto_adp_serial_id).ToList();
                //    List<int?> termsList = new List<int?>();
                //    foreach (var item in distIds)
                //    {
                //        termsList.Add(item.Distt_ID);
                //    }
                //    model.DistIds = termsList;
                //}
                model.RequestStatus = "Ok";
            }
            catch (Exception)
            {
                model.RequestStatus = "Error";
            }

            return(model);
        }