Пример #1
0
        public IHttpActionResult GetTopRecentDonator(int top)
        {
            try
            {
                List <DonationDTO> topRecentDonator;


                using (var db = new DonationDAL())
                {
                    topRecentDonator = db.GetTopRecentlyDonator(top);
                }

                return(Ok(new HTTPMessageDTO
                {
                    Status = WsConstant.HttpMessageType.SUCCESS,
                    Message = "",
                    Type = "",
                    Data = topRecentDonator
                }));
            }
            catch (Exception)
            {
                return(Ok(new HTTPMessageDTO
                {
                    Status = WsConstant.HttpMessageType.ERROR,
                    Message = "",
                    Type = ""
                }));
            }
        }
Пример #2
0
        public ResultBM Delete(object entity)
        {
            try
            {
                DonationDAL donationDal = new DonationDAL();
                DonationBM  donationBm  = entity as DonationBM;

                if (donationBm.IsReceived())
                {
                    if (!donationDal.IsInUse(donationBm.id))
                    {
                        donationDal.DeleteDonation(donationBm.id);
                        return(new ResultBM(ResultBM.Type.OK, "Se ha eliminado el registro.", donationBm));
                    }
                    else
                    {
                        return(new ResultBM(ResultBM.Type.FAIL, SessionHelper.GetTranslation("DONATION_ASSIG_UNDELETEABLE_ERROR"), donationBm));
                    }
                }
                else
                {
                    return(new ResultBM(ResultBM.Type.FAIL, SessionHelper.GetTranslation("DONATION_STATUS_UNDELETEABLE_ERROR"), donationBm));
                }
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("DELETING_ERROR") + " " + exception.Message, exception));
            }
        }
Пример #3
0
        public IHttpActionResult GetTopMostDonatedUser()
        {
            try
            {
                var topTenDonate = new List <UserBasicInfoDTO>();


                using (var db = new DonationDAL())
                {
                    topTenDonate = db.GetTopNumberDonator(5);
                }

                return(Ok(new HTTPMessageDTO
                {
                    Status = WsConstant.HttpMessageType.SUCCESS,
                    Message = "",
                    Type = "",
                    Data = topTenDonate
                }));
            }
            catch (Exception)
            {
                return(Ok(new HTTPMessageDTO
                {
                    Status = WsConstant.HttpMessageType.ERROR,
                    Message = "",
                    Type = ""
                }));
            }
        }
Пример #4
0
 public IHttpActionResult GetAllDonationBasicInformation()
 {
     try
     {
         List <DonationDTO> listDonation;
         using (var db = new DonationDAL())
         {
             listDonation = db.GetAllDonation();
         }
         return(Ok(new HTTPMessageDTO
         {
             Status = WsConstant.HttpMessageType.SUCCESS,
             Data = listDonation
         }));
     }
     catch (Exception)
     {
         return(Ok(new HTTPMessageDTO
         {
             Status = WsConstant.HttpMessageType.ERROR,
             Message = "Cannot Get Donation Information",
             Type = ""
         }));
     }
 }
Пример #5
0
        public ResultBM GetDonation(int donationId)
        {
            try
            {
                VolunteerBLL      volunteerBll      = new VolunteerBLL();
                ResultBM          volunteerResult   = null;
                VolunteerBM       volunteerBm       = null;
                DonationStatusBLL donationStatusBll = new DonationStatusBLL();
                ResultBM          statusResult      = null;
                DonorBLL          donorBll          = new DonorBLL();
                ResultBM          donorResult       = null;

                DonationDAL donationDal = new DonationDAL();
                DonationBM  donationBm  = null;
                DonationDTO donationDto = donationDal.GetDonation(donationId);

                //Si la donación existe, debería existir el estado
                if (donationDto != null)
                {
                    statusResult = donationStatusBll.GetDonationStatus(donationDto.statusId);
                    if (!statusResult.IsValid())
                    {
                        return(statusResult);
                    }
                    if (statusResult.GetValue() == null)
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " statusId " + donationDto.statusId);
                    }

                    donorResult = donorBll.GetDonor(donationDto.donorId);
                    if (!donorResult.IsValid())
                    {
                        return(donorResult);
                    }
                    if (donorResult.GetValue() == null)
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " donorId " + donationDto.donorId);
                    }

                    //Podría no existir voluntario, sobre todo si se consulta una donación recién creada
                    volunteerResult = volunteerBll.GetVolunteer(donationDto.volunteerId);
                    if (volunteerResult.GetValue() != null)
                    {
                        volunteerBm = volunteerResult.GetValue <VolunteerBM>();
                    }

                    donationBm = new DonationBM(donationDto, donorResult.GetValue <DonorBM>(), statusResult.GetValue <DonationStatusBM>(), volunteerBm);
                }

                return(new ResultBM(ResultBM.Type.OK, "Operación exitosa.", donationBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
            }
        }
Пример #6
0
 public ResultBM GetAvaliableDonations()
 {
     try {
         DonationDAL        donationDal  = new DonationDAL();
         List <DonationDTO> donationsDto = donationDal.GetAvaliableDonations();
         List <DonationBM>  donationsBm  = ConvertIntoBusinessModel(donationsDto);
         return(new ResultBM(ResultBM.Type.OK, "Recuperación de registros exitosa.", donationsBm));
     }
     catch (Exception exception) {
         return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
     }
 }
Пример #7
0
        public IHttpActionResult GeUsertDonationInformation(string userName)
        {
            try
            {
                List <DonationDTO> userDonationInfor = new List <DonationDTO>();
                List <int>         donationIdList    = new List <int>();

                using (var db = new Ws_DataContext())
                {
                    var user = db.Ws_User.FirstOrDefault(x => x.UserName == userName);
                    if (user != null)
                    {
                        int userId = user.UserID;
                        donationIdList = db.Donations.Where(x => x.UserId == userId).Select(x => x.DonationId).ToList();
                    }
                }

                foreach (int donationId in donationIdList)
                {
                    DonationDTO donation;
                    using (var db = new DonationDAL())
                    {
                        donation = db.GetFullInformationOfDonation(donationId);
                    }

                    userDonationInfor.Add(donation);
                }

                return(Ok(new HTTPMessageDTO
                {
                    Status = WsConstant.HttpMessageType.SUCCESS,
                    Message = "Get User Profile Successfully",
                    Type = "",
                    Data = userDonationInfor
                }));
            }
            catch (Exception)
            {
                return(Ok(new HTTPMessageDTO
                {
                    Status = WsConstant.HttpMessageType.ERROR,
                    Message = "Cannot Get User Donation Infomation!",
                    Type = ""
                }));
            }
        }
Пример #8
0
        public ResultBM UpdateDonation(DonationBM donationBm)
        {
            try
            {
                DonationDAL donationDal = new DonationDAL();
                DonationDTO donationDto;
                ResultBM    validationResult = IsValid(donationBm);

                if (!validationResult.IsValid())
                {
                    return(validationResult);
                }
                donationDto = new DonationDTO(donationBm.Items, donationBm.Arrival, donationBm.donationStatus.id, donationBm.donor.donorId, donationBm.Comment, donationBm.volunteer == null ? 0 : donationBm.volunteer.volunteerId, donationBm.id);
                donationDal.UpdateDonation(donationDto);

                return(new ResultBM(ResultBM.Type.OK, "Se ha actualizado la donación.", donationBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("UPDATING_ERROR") + " " + exception.Message, exception));
            }
        }
Пример #9
0
 public ActionResult DonationComplete()
 {
     try
     {
         //check exist DonatedInfo Session
         if (Session["DonatedInfo"] == null)
         {
             return(null);
         }
         else
         {
             //Get data in session and transactiondetail and return to view
             var newDonate = (DonationDTO)Session["DonatedInfo"];
             newDonate.DonatedDate = DateTime.Now.ToString("hh:mm dd/MM/yy");
             RequestCheckOrder info = new RequestCheckOrder();
             info.Merchant_id       = "48283";
             info.Merchant_password = "******";
             info.Token             = newDonate.TradeCode;
             APICheckoutV3      objNLChecout = new APICheckoutV3();
             ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);
             using (var db = new DonationDAL())
             {
                 db.AddNewDonation(newDonate);
             }
             using (var db = new EventDAL())
             {
                 newDonate.EventName = db.GetEventNameById(newDonate.EventId);
             }
             Session.Remove("DonatedInfo");
             return(PartialView("~/Views/Donation/_DonationDone.cshtml", newDonate));
         }
     }
     catch (Exception)
     {
         return(PartialView("~/Views/Error/_Error.cshtml"));
     }
 }
Пример #10
0
        public void UpdateToReceivedStatus(int id)
        {
            DonationDAL donationDal = new DonationDAL();

            donationDal.UpdateToStatus(id, (int)DonationStatusBM.Status.RECEIVED);
        }
Пример #11
0
        public void UpdateToStoredStatusIfApply(int id)
        {
            DonationDAL donationDal = new DonationDAL();

            donationDal.UpdateStatusToStored(id, (int)DonationStatusBM.Status.STORED);
        }