Example #1
0
        public static LockerCollectionPointModel GetLockerCPByLockerid(int lockerid, out string error)
        {
            error = "";

            LUSSISEntities             entities = new LUSSISEntities();
            lockercollectionpoint      lcp      = new lockercollectionpoint();
            LockerCollectionPointModel lcpm     = new LockerCollectionPointModel();

            try
            {
                lcp  = entities.lockercollectionpoints.Where(p => p.lockerid == lockerid).FirstOrDefault <lockercollectionpoint>();
                lcpm = ConvertBDLockerCPToAPILockerCP(lcp);
            }
            catch (NullReferenceException)
            {
                // if there is NULL Exception error, error will be 404
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                // for other exceptions
                error = e.Message;
            }
            return(lcpm);
        }
Example #2
0
        public static DisbursementLockerModel UpdateDisbursementLockerToCollected(DisbursementLockerModel lislm, out string error)
        {
            error = "";
            // entites used only by Get Methods
            LUSSISEntities          entities = new LUSSISEntities();
            disbursementlocker      disl     = new disbursementlocker();
            DisbursementLockerModel dislm    = new DisbursementLockerModel();

            try
            {
                disl = entities.disbursementlockers.Where(p => p.reqid == lislm.ReqID && p.lockerid == lislm.LockerID).FirstOrDefault();

                disl.collecteddate = DateTime.Now;
                disl.status        = 0;
                entities.SaveChanges();

                lockercollectionpoint lcp = entities.lockercollectionpoints.Where(p => p.lockerid == disl.lockerid).FirstOrDefault();
                lcp.status = ConLockerCollectionPoint.Active.AVAILABLE;

                entities.SaveChanges();


                dislm = GetDisbursementLockerByReqIDAndLockerID(disl.reqid, disl.lockerid, out error);
            }

            // if locker not found, will throw NOTFOUND exception
            catch (NullReferenceException)
            {
                // if there is NULL Exception error, error will be 404
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                // for other exceptions
                error = e.Message;
            }
            //retuning the lockercollectionpoint object
            return(dislm);
        }
Example #3
0
        public static LockerCollectionPointModel UpdateLockerCP(LockerCollectionPointModel lcpm, out string error)
        {
            // Initializing the error variable to return only blank if there is no error
            error = "";
            // declare and initialize new LUSSISEntities to perform update
            LUSSISEntities        entities = new LUSSISEntities();
            lockercollectionpoint lcp      = new lockercollectionpoint();

            try
            {
                // finding the lockercollectionpoint by lockerid
                lcp = entities.lockercollectionpoints.Where(p => p.lockerid == lcpm.Lockerid).First <lockercollectionpoint>();

                // transfering data from API model to DB Model
                lcp.lockername = lcpm.Lockername;
                lcp.lockersize = lcpm.Lockersize;
                lcp.cpid       = lcpm.Cpid;
                lcp.status     = lcpm.Status;

                // saving the update
                entities.SaveChanges();

                // return the updated model
                lcpm = ConvertBDLockerCPToAPILockerCP(lcp);
            }
            // if locker not found, will throw NOTFOUND exception
            catch (NullReferenceException)
            {
                // if there is NULL Exception error, error will be 404
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                // for other exceptions
                error = e.Message;
            }
            //returning the lockercollectionpoint object
            return(lcpm);
        }
Example #4
0
        public static LockerCollectionPointModel GetLockerCPByLockername(string lockername, out string error)
        {
            error = "";
            // declare and initialize new LUSSISEntities to get LockerCollectionPoint By LockerName
            LUSSISEntities entities = new LUSSISEntities();

            lockercollectionpoint      lcp  = new lockercollectionpoint();
            LockerCollectionPointModel lcpm = new LockerCollectionPointModel();

            try
            {
                lcp  = entities.lockercollectionpoints.Where(p => p.lockername == lockername).FirstOrDefault <lockercollectionpoint>();
                lcpm = ConvertBDLockerCPToAPILockerCP(lcp);
            }
            catch (NullReferenceException)
            {
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(lcpm);
        }
Example #5
0
        public static LockerCollectionPointModel CreateLockerCP(LockerCollectionPointModel lcpm, out string error)
        {
            error = "";
            // entites used only by Get Methods
            LUSSISEntities        entities = new LUSSISEntities();
            lockercollectionpoint lcp      = new lockercollectionpoint();

            try
            {
                // transfering data from API model to DB Model
                lcp.lockername = lcpm.Lockername;
                lcp.lockersize = lcpm.Lockersize;
                lcp.cpid       = lcpm.Cpid;
                lcp.status     = lcpm.Status;
                //Add the updated data to DB Model
                lcp = entities.lockercollectionpoints.Add(lcp);
                // saving the update
                entities.SaveChanges();
                //retrieving the LockerColletionPoint By Lockerid
                lcpm = GetLockerCPByLockerid(lcp.lockerid, out error);
            }

            // if locker not found, will throw NOTFOUND exception
            catch (NullReferenceException)
            {
                // if there is NULL Exception error, error will be 404
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                // for other exceptions
                error = e.Message;
            }
            //retuning the lockercollectionpoint object
            return(lcpm);
        }
Example #6
0
        // Convert From Auto Generated DB Model to APIModel
        private static LockerCollectionPointModel ConvertBDLockerCPToAPILockerCP(lockercollectionpoint lcp)
        {
            LockerCollectionPointModel lcpm = new LockerCollectionPointModel(lcp.lockerid, lcp.lockername, lcp.lockersize, lcp.cpid, lcp.status, lcp.collectionpoint.cpname);

            return(lcpm);
        }