public ActionResult ManageAPForOutdoor(
            )
        {
            string      ImageSHPPath = "";
            APViewModel model        = new APViewModel();

            var files = Request.Form.Files;

            if (files.Count > 0)
            {
                model.Image = files[0];
            }

            model.APID        = Convert.ToInt32(Request.Form.Where(x => x.Key == "apid").FirstOrDefault().Value);
            model.Lat         = Convert.ToDouble(Request.Form.Where(x => x.Key == "newlat").FirstOrDefault().Value);
            model.Long        = Convert.ToDouble(Request.Form.Where(x => x.Key == "newlong").FirstOrDefault().Value);
            model.Name        = Request.Form.Where(x => x.Key == "name").FirstOrDefault().Value;
            model.Description = Request.Form.Where(x => x.Key == "desc").FirstOrDefault().Value;

            bool res = true;

            if (files.Count > 0)
            {
                res = UploadFile(model.Image, out ImageSHPPath);
                model.ImageSHPPath = ImageSHPPath;
            }
            else
            {
                model.ImageSHPPath = Request.Form.Where(x => x.Key == "ImageSHPPath").FirstOrDefault().Value;;
                //if (HttpContext.Session.GetString("ImagePath") != null)
                //{
                //    model.ImageSHPPath = HttpContext.Session.GetString("ImagePath");
                //}
                //else
                //{
                //    return Json(new { Result = false, APID = model.APID }, new JsonSerializerSettings());
                //}
            }


            if (model.APID == 0)
            {
                //insert
                result     = _APBAL.AddAP(model, true);
                model.APID = Convert.ToInt32(result.Values);
            }
            else
            {
                //update
                result = _APBAL.UpdateAP(model, true);
            }



            //  return Json(new { Result = true, APID = model.APID }, JsonRequestBehavior.AllowGet);
            var sa = new JsonSerializerSettings();

            //   return Json(new { Result = true, APID = model.APID }, JsonRequestBehavior.AllowGet);
            return(Json(new { Result = true, APID = model.APID }, sa));
        }
        public ActionResult ManageAPNew(
            int apid,
            double newlat,
            double newlong,
            string name,
            string desc,
            int floorID
            )
        {
            APViewModel model = new APViewModel();

            model.APID        = apid;
            model.Lat         = newlat;
            model.Long        = newlong;
            model.Name        = name;
            model.Description = desc;
            model.FloorID     = floorID;
            if (model.APID == 0)
            {
                //insert
                result     = _APBAL.AddAP(model);
                model.APID = Convert.ToInt32(result.Values);
            }
            else
            {
                //update
                result = _APBAL.UpdateAP(model);
            }
            var sa = new JsonSerializerSettings();

            //   return Json(new { Result = true, APID = model.APID }, JsonRequestBehavior.AllowGet);
            return(Json(new { Result = true, APID = model.APID }, sa));
        }
        public ActionResult Index(int id, int numeroFinca)
        {
            APViewModel movimientos = new APViewModel()
            {
                APs         = AP_Conexion.SelectMovimientos(id),
                numeroFinca = numeroFinca
            };

            return(View(movimientos));
        }
Beispiel #4
0
        public List <APViewModel> GetAPByFloorID(int floorID)
        {
            DBOperations       dbOps = new DBOperations();
            List <APViewModel> objs  = new List <APViewModel>();

            try
            {
                NpgsqlParameter[] aParams = new NpgsqlParameter[1];
                aParams[0]       = new NpgsqlParameter("_floorid", NpgsqlTypes.NpgsqlDbType.Integer);
                aParams[0].Value = floorID;

                dbOps.ExecuteReader(AppConstants.usp_GETAPSBYFLOORID, aParams);

                if (!(dbOps.DataReader == null))
                {
                    using (dbOps.DataReader)
                    {
                        while (dbOps.DataReader.Read())
                        {
                            APViewModel obj = new APViewModel
                            {
                                APID         = Helper.HandleDBNull <Int32>(dbOps.DataReader[0]),
                                Name         = Helper.HandleDBNull <String>(dbOps.DataReader[1]),
                                Lat          = Helper.HandleDBNull <double>(dbOps.DataReader[2]),
                                Long         = Helper.HandleDBNull <double>(dbOps.DataReader[3]),
                                Description  = Helper.HandleDBNull <String>(dbOps.DataReader[4]),
                                FloorID      = Helper.HandleDBNull <int>(dbOps.DataReader[5]),
                                ImageSHPPath = Helper.HandleDBNull <String>(dbOps.DataReader[6]),
                                APTypeID     = Helper.HandleDBNull <int>(dbOps.DataReader[7]),
                                GroupID      = Helper.HandleDBNull <int>(dbOps.DataReader[8]),
                                SerialNo     = Helper.HandleDBNull <string>(dbOps.DataReader[9]),
                            };

                            objs.Add(obj);
                        }
                    }
                }
                return(objs);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
Beispiel #5
0
        public List <APViewModel> GetAPByOutdoorMasterID(int?floorID)
        {
            DBOperations       dbOps = new DBOperations();
            List <APViewModel> objs  = new List <APViewModel>();

            try
            {
                NpgsqlParameter[] aParams = new NpgsqlParameter[1];
                aParams[0]       = new NpgsqlParameter("_outdoormasterid", NpgsqlTypes.NpgsqlDbType.Integer);
                aParams[0].Value = floorID;

                dbOps.ExecuteReader(AppConstants.usp_GETAPSBYOutdoorMasterID, aParams);

                if (!(dbOps.DataReader == null))
                {
                    using (dbOps.DataReader)
                    {
                        while (dbOps.DataReader.Read())
                        {
                            APViewModel obj = new APViewModel
                            {
                                APID         = Helper.HandleDBNull <Int32>(dbOps.DataReader[0]),
                                Name         = Helper.HandleDBNull <String>(dbOps.DataReader[1]),
                                Lat          = Helper.HandleDBNull <double>(dbOps.DataReader[2]),
                                Long         = Helper.HandleDBNull <double>(dbOps.DataReader[3]),
                                Description  = Helper.HandleDBNull <String>(dbOps.DataReader[4]),
                                ImageSHPPath = Helper.HandleDBNull <String>(dbOps.DataReader[5]),
                                listAPSector = GetAPSectorByOutdoorAPID(Helper.HandleDBNull <Int32>(dbOps.DataReader[0]))
                            };

                            objs.Add(obj);
                        }
                    }
                }
                return(objs);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
Beispiel #6
0
        public APViewModel GetAPByID(int _id)
        {
            DBOperations dbOps = new DBOperations();
            APViewModel  obj   = null;

            try
            {
                //dbOps.ProcName = AppConstants.USP_GETINSTALLATIONPARAMETERSBYID;

                NpgsqlParameter[] aParams = new NpgsqlParameter[1];
                aParams[0]       = new NpgsqlParameter("_id", NpgsqlTypes.NpgsqlDbType.Integer);
                aParams[0].Value = _id;

                dbOps.ExecuteReader(AppConstants.USP_GETAPBYID, aParams);

                if (!(dbOps.DataReader == null))
                {
                    using (dbOps.DataReader)
                    {
                        while (dbOps.DataReader.Read())
                        {
                            obj = new APViewModel
                            {
                                APID        = Helper.HandleDBNull <Int32>(dbOps.DataReader[0]),
                                Name        = Helper.HandleDBNull <String>(dbOps.DataReader[1]),
                                Lat         = Helper.HandleDBNull <double>(dbOps.DataReader[2]),
                                Long        = Helper.HandleDBNull <double>(dbOps.DataReader[3]),
                                Description = Helper.HandleDBNull <String>(dbOps.DataReader[4]),
                                FloorID     = Helper.HandleDBNull <int>(dbOps.DataReader[5]),
                            };
                        }
                    }
                }
                return(obj);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
Beispiel #7
0
        // GET: AP
        public ActionResult Index()
        {
            var now       = DateTime.Now;
            var startDate = new DateTime(now.Year, now.Month, 1);
            var vm        = new APViewModel {
                BillingCycleRecords = new List <BillingCycleRecord> {
                    new BillingCycleRecord {
                        ClaimCount     = 83441,
                        ClaimId        = 11,
                        Date           = startDate,
                        CycleStatus    = "Processing",
                        PharmacyPaid   = 481165.88M,
                        UniquePayments = 12485
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 77232,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-1),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 393643.16M,
                        UniquePayments = 12012
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 88123,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-2),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 549346.71M,
                        UniquePayments = 14232
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 83522,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-3),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 523121.11M,
                        UniquePayments = 13872
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 80122,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-4),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 462211.52M,
                        UniquePayments = 12442
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 81332,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-5),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 484221.22M,
                        UniquePayments = 12485
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 90112,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-6),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 554632.63M,
                        UniquePayments = 14201
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 74220,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-7),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 395122.12M,
                        UniquePayments = 12422
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 79899,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-8),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 463343.23M,
                        UniquePayments = 13422
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 94988,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-9),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 621212.12M,
                        UniquePayments = 15232
                    },
                    new BillingCycleRecord {
                        ClaimCount     = 82990,
                        ClaimId        = 11,
                        Date           = startDate.AddMonths(-10),
                        CycleStatus    = "Complete",
                        PharmacyPaid   = 512363.63M,
                        UniquePayments = 14232
                    },
                }
            };

            vm.AnnualTotal = vm.BillingCycleRecords.Sum(bc => bc.PharmacyPaid);
            vm.AvgMonth    = vm.AnnualTotal / vm.BillingCycleRecords.Count;

            var claimCountTotal   = vm.BillingCycleRecords.Sum(bc => bc.ClaimCount);
            var paymentCountTotal = vm.BillingCycleRecords.Sum(bc => bc.UniquePayments);

            vm.AvgClaimCount   = claimCountTotal / vm.BillingCycleRecords.Count;
            vm.AvgPaymentCount = paymentCountTotal / vm.BillingCycleRecords.Count;

            return(View(vm));
        }
Beispiel #8
0
        public Result UpdateAP(APViewModel model, bool isOutdoor = false)
        {
            Result       result = new Result();
            DBOperations dbOps  = new DBOperations();

            try
            {
                NpgsqlParameter[] aParams;
                if (!isOutdoor)
                {
                    aParams = new NpgsqlParameter[14];
                }
                else
                {
                    aParams = new NpgsqlParameter[9];
                }



                aParams[0]       = new NpgsqlParameter("Name", NpgsqlTypes.NpgsqlDbType.Varchar);
                aParams[0].Value = model.Name;



                aParams[1]       = new NpgsqlParameter("Lat", NpgsqlTypes.NpgsqlDbType.Double);
                aParams[1].Value = model.Lat;



                aParams[2]       = new NpgsqlParameter("Long", NpgsqlTypes.NpgsqlDbType.Double);
                aParams[2].Value = model.Long;



                aParams[3]       = new NpgsqlParameter("Description", NpgsqlTypes.NpgsqlDbType.Varchar);
                aParams[3].Value = model.Description;



                aParams[4]       = new NpgsqlParameter(AppConstants.LastModifiedOn, NpgsqlTypes.NpgsqlDbType.Timestamp);
                aParams[4].Value = DateTime.Now;



                aParams[5]       = new NpgsqlParameter(AppConstants.LastModifiedBy, NpgsqlTypes.NpgsqlDbType.Integer);
                aParams[5].Value = 0;



                aParams[6]       = new NpgsqlParameter("IsActive", NpgsqlTypes.NpgsqlDbType.Boolean);
                aParams[6].Value = true;



                if (isOutdoor)
                {
                    aParams[7]       = new NpgsqlParameter("APImagePath", NpgsqlTypes.NpgsqlDbType.Varchar);
                    aParams[7].Value = model.ImageSHPPath;
                }
                int i = 8;
                if (!isOutdoor)
                {
                    // aParams[8] = new NpgsqlParameter("FloorID", NpgsqlTypes.NpgsqlDbType.Integer);
                    // aParams[8].Value = model.FloorID;

                    aParams[7]        = new NpgsqlParameter("FloorID", NpgsqlTypes.NpgsqlDbType.Integer);
                    aParams[7].Value  = model.FloorID;
                    aParams[8]        = new NpgsqlParameter("APTypeID", NpgsqlTypes.NpgsqlDbType.Integer);
                    aParams[8].Value  = model.APTypeID;
                    aParams[9]        = new NpgsqlParameter("GroupID", NpgsqlTypes.NpgsqlDbType.Integer);
                    aParams[9].Value  = model.GroupID;
                    aParams[10]       = new NpgsqlParameter("IsIndoor", NpgsqlTypes.NpgsqlDbType.Boolean);
                    aParams[10].Value = true;
                    aParams[11]       = new NpgsqlParameter("APimagepath", NpgsqlTypes.NpgsqlDbType.Varchar);
                    aParams[11].Value = model.ImageSHPPath;
                    aParams[12]       = new NpgsqlParameter("SerialNo", NpgsqlTypes.NpgsqlDbType.Varchar);
                    aParams[12].Value = model.SerialNo;

                    i = 13;
                }



                aParams[i]       = new NpgsqlParameter("APID", NpgsqlTypes.NpgsqlDbType.Integer);
                aParams[i].Value = model.APID;
                int res = 0;
                if (!isOutdoor)
                {
                    res = dbOps.ExecuteNonQuery(AppConstants.QueryConstants.UpdateAP, aParams);
                }
                else
                {
                    res = dbOps.ExecuteNonQuery(AppConstants.QueryConstants.UpdateAPForOutdoor, aParams);
                }



                if (res > 0)
                {
                    result.Status = Status.Success;
                }
                else
                {
                    result.Status = Status.Failure;
                }
            }
            catch (Exception Ex)
            {
                dbOps.Abort();
                result.Status = Status.Failure;
            }
            return(result);
        }
Beispiel #9
0
        public Result AddAP(APViewModel model, bool isOutdoor = false)
        {
            Result       result = new Result();
            DBOperations dbOps  = new DBOperations();

            try
            {
                NpgsqlParameter[] aParams;
                if (!isOutdoor)
                {
                    aParams = new NpgsqlParameter[11];
                }
                else
                {
                    aParams = new NpgsqlParameter[6];
                }

                aParams[0]       = new NpgsqlParameter("Name", NpgsqlTypes.NpgsqlDbType.Varchar);
                aParams[0].Value = model.Name;

                aParams[1]       = new NpgsqlParameter("Lat", NpgsqlTypes.NpgsqlDbType.Double);
                aParams[1].Value = model.Lat;

                aParams[2]       = new NpgsqlParameter("Long", NpgsqlTypes.NpgsqlDbType.Double);
                aParams[2].Value = model.Long;

                aParams[3]       = new NpgsqlParameter("Description", NpgsqlTypes.NpgsqlDbType.Varchar);
                aParams[3].Value = model.Description;


                aParams[4]       = new NpgsqlParameter(AppConstants.CreatedBy, NpgsqlTypes.NpgsqlDbType.Integer);
                aParams[4].Value = 0;



                if (!isOutdoor)
                {
                    aParams[5]        = new NpgsqlParameter("FloorID", NpgsqlTypes.NpgsqlDbType.Integer);
                    aParams[5].Value  = model.FloorID;
                    aParams[6]        = new NpgsqlParameter("APTypeID", NpgsqlTypes.NpgsqlDbType.Integer);
                    aParams[6].Value  = model.APTypeID;
                    aParams[7]        = new NpgsqlParameter("GroupID", NpgsqlTypes.NpgsqlDbType.Integer);
                    aParams[7].Value  = model.GroupID;
                    aParams[8]        = new NpgsqlParameter("IsIndoor", NpgsqlTypes.NpgsqlDbType.Boolean);
                    aParams[8].Value  = true;
                    aParams[9]        = new NpgsqlParameter("APimagepath", NpgsqlTypes.NpgsqlDbType.Varchar);
                    aParams[9].Value  = model.ImageSHPPath;
                    aParams[10]       = new NpgsqlParameter("SerialNo", NpgsqlTypes.NpgsqlDbType.Varchar);
                    aParams[10].Value = model.SerialNo;
                }
                if (isOutdoor)
                {
                    aParams[5]       = new NpgsqlParameter("APImagePath", NpgsqlTypes.NpgsqlDbType.Varchar);
                    aParams[5].Value = model.ImageSHPPath;
                }


                int res = 0;
                if (!isOutdoor)
                {
                    res = (int)dbOps.ExecuteScalar(AppConstants.QueryConstants.AddAP, aParams);
                }
                else
                {
                    res = (int)dbOps.ExecuteScalar(AppConstants.QueryConstants.AddAPForOutdoor, aParams);
                }

                if (res > 0)
                {
                    result.Status = Status.Success;
                    result.Values = res.ToString();
                }
                else
                {
                    result.Status = Status.Failure;
                }
            }
            catch (Exception Ex)
            {
                dbOps.Abort();
                result.Status = Status.Failure;
            }
            return(result);
        }