Exemple #1
0
        private ResultStatus AddBooking(GEMA_TR_BOOKING booking, ref int booking_id)
        {
            _ctx.GEMA_TR_BOOKING.Add(booking);
            _ctx.SaveChanges();

            booking_id = _ctx.GEMA_TR_BOOKING.Where(x => x.TR_NUMBER == booking.TR_NUMBER).FirstOrDefault().ID;
            rs.SetSuccessStatus();

            return(rs);
        }
Exemple #2
0
        public ResultStatus Delete(int id, string modifiedBy, DateTime modifiedTime)
        {
            try
            {
                GEMA_TR_BOOKING booking = _ctx.GEMA_TR_BOOKING.Find(id);
                booking.LAST_MODIFIED_TIME = modifiedTime;
                booking.LAST_MODIFIED_BY   = modifiedBy;
                booking.ROW_STATUS         = eStat.fg.NotActive;

                _ctx.Entry(booking).State = EntityState.Modified;
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Exemple #3
0
        public ResultStatus Edit(GEMA_TR_BOOKING booking)
        {
            using (var transaction = _ctx.Database.BeginTransaction())
            {
                try
                {
                    GEMA_TR_BOOKING bookingNew = _ctx.GEMA_TR_BOOKING.Find(booking.ID);
                    if (booking.STATUS == (int)EnumList.BookingStatus.Submitted)
                    {
                        bookingNew.STATUS               = (int)EnumList.BookingStatus.Uploaded;
                        bookingNew.RECEIVE_PAYMENT_BY   = booking.LAST_MODIFIED_BY;
                        bookingNew.RECEIVE_PAYMENT_TIME = booking.LAST_MODIFIED_TIME;
                        bookingNew.PAYMENT_IMAGE_PATH   = booking.PAYMENT_IMAGE_PATH;
                    }
                    else if (booking.STATUS == (int)EnumList.BookingStatus.Uploaded)
                    {
                        bookingNew.STATUS = (int)EnumList.BookingStatus.Completed;
                        bookingNew.COMPLETE_PAYMENT_BY   = booking.LAST_MODIFIED_BY;
                        bookingNew.COMPLETE_PAYMENT_TIME = booking.LAST_MODIFIED_TIME;
                    }

                    bookingNew.LAST_MODIFIED_TIME = booking.LAST_MODIFIED_TIME;
                    bookingNew.LAST_MODIFIED_BY   = booking.LAST_MODIFIED_BY;
                    _ctx.Entry(bookingNew).State  = System.Data.Entity.EntityState.Modified;
                    _ctx.SaveChanges();
                    rs.SetSuccessStatus();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    rs.SetErrorStatus(ex.Message);
                    transaction.Rollback();
                }
            }

            return(rs);
        }
Exemple #4
0
        public ResultStatus Add(GEMA_TR_BOOKING booking)
        {
            using (var transaction = _ctx.Database.BeginTransaction())
            {
                try
                {
                    int booking_id = 0;
                    rs = AddBooking(booking, ref booking_id);
                    if (rs.IsSuccess)
                    {
                        rs = AddBookingDetail(booking.GEMA_TR_BOOKING_DETAIL.FirstOrDefault(), booking_id);
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    rs.SetErrorStatus(ex.Message);
                    transaction.Rollback();
                }
            }

            return(rs);
        }