コード例 #1
0
        public bool UpdatePackageArrangements(arrangement_package arrangementObj)
        {
            Models.apartma2Entities entities = new Models.apartma2Entities();
            try
            {
                Models.arrangement_package arrangementModel = entities.arrangement_package.FirstOrDefault(el => el.id.Equals(arrangementObj.id));
                if (arrangementModel != null)
                {
                    arrangementModel.id              = arrangementObj.id;
                    arrangementModel.title           = arrangementObj.title;
                    arrangementModel.description     = arrangementObj.description;
                    arrangementModel.max_resevations = arrangementObj.max_reservations.ToString();
                    arrangementModel.valid_to        = arrangementObj.valid_to;
                    arrangementModel.valid_from      = arrangementObj.valid_from;
                    arrangementModel.price           = (float)arrangementObj.price;

                    entities.Entry(arrangementModel).State = System.Data.Entity.EntityState.Modified;
                    entities.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #2
0
        public int MakeBooking(string user_trr, int apartmentId, int dateFrom, int dateTo, int package_arrangment_id, string discountCode, bool bank_payment)
        {
            Models.apartma2Entities entities = new Models.apartma2Entities();
            try
            {
                Models.apartment apartmentModel = entities.apartments.FirstOrDefault(el => el.id.Equals(apartmentId));

                if (apartmentModel != null)
                {
                    Models.payment_method method = new Models.payment_method();
                    method.bank_payment = bank_payment;                     // true -> e-bull; false -> card
                    method.card_number  = user_trr.ToString();

                    Models.booking newBooking = new Models.booking();
                    newBooking.customer_trr          = user_trr;
                    newBooking.apartment_idapartment = apartmentId;
                    newBooking.date_from             = dateFrom;
                    newBooking.date_to        = dateTo;
                    newBooking.payment_method = method;

                    if (bank_payment)
                    {
                        newBooking.status = "pending";
                    }
                    else
                    {
                        newBooking.status = "paid";
                    }

                    Models.arrangement_package arrangementModel = entities.arrangement_package.FirstOrDefault(el => el.id.Equals(package_arrangment_id));
                    Models.discount            discountModel    = entities.discounts.FirstOrDefault(el => el.code.Equals(discountCode));

                    if (arrangementModel != null)
                    {
                        newBooking.arrangement_package_id = arrangementModel.id;
                    }


                    if (discountModel != null)
                    {
                        newBooking.discounts_id = discountModel.id;
                    }

                    entities.bookings.Add(newBooking);
                    entities.SaveChanges();
                    return(newBooking.id);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
コード例 #3
0
 public static Types.arrangement_package ArrangmentModelToObj(Models.arrangement_package model)
 {
     Types.arrangement_package obj = new Types.arrangement_package
     {
         id               = model.id,
         title            = model.title,
         description      = model.description,
         max_reservations = Convert.ToInt32(model.max_resevations),
         valid_from       = (int)model.valid_from,
         valid_to         = (int)model.valid_to,
         price            = (float)model.price
     };
     return(obj);
 }
コード例 #4
0
 public static Models.arrangement_package ArrangmentObjToModel(Types.arrangement_package obj)
 {
     Models.arrangement_package model = new Models.arrangement_package
     {
         id              = obj.id,
         title           = obj.title,
         description     = obj.description,
         max_resevations = obj.max_reservations.ToString(),
         valid_from      = obj.valid_from,
         valid_to        = obj.valid_to,
         price           = (float)obj.price
     };
     return(model);
 }
コード例 #5
0
 public int AddPackageArrangments(arrangement_package arrangmentObj)
 {
     Models.apartma2Entities entities = new Models.apartma2Entities();
     try
     {
         Models.arrangement_package arrangmentModel = ApartmentTypeConverter.ArrangmentObjToModel(arrangmentObj);
         entities.arrangement_package.Add(arrangmentModel);
         entities.SaveChanges();
         return(arrangmentModel.id);
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
コード例 #6
0
 public bool AddPackageArrangments(arrangement_package arrangmentObj)
 {
     Models.ApartmentEntities entities = new Models.ApartmentEntities();
     try
     {
         Models.arrangement_package arrangmentModel = ApartmentTypeConverter.ArrangmentObjToModel(arrangmentObj);
         entities.arrangement_package.Add(arrangmentModel);
         entities.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #7
0
 public bool DeletePackageArrangments(int arrangementId)
 {
     Models.apartma2Entities entities = new Models.apartma2Entities();
     try
     {
         Models.arrangement_package arrangementModel = entities.arrangement_package.FirstOrDefault(el => el.id.Equals(arrangementId));
         if (arrangementModel != null)
         {
             entities.Entry(arrangementModel).State = System.Data.Entity.EntityState.Deleted;
             entities.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }