public IActionResult SaveSurgePrice(SurgePrice surgePrice)
 {
     try
     {
         DAVechile dATypes = new DAVechile();
         return(this.OKResponse(dATypes.SaveSurgePrice(surgePrice, _context, User.ToAppUser()) ? "Updated Successfully" : "Failed to Update"));
     }
     catch (TaxiAppsWebAPICore.Helper.DataValidationException ex)
     {
         return(this.KnowOperationError(ex.Message));
     }
 }
Beispiel #2
0
        public bool SaveSurgePrice(SurgePrice surgePrice, TaxiAppzDBContext content, LoggedInUser loggedIn)
        {
            var existZone = content.TabZone.FirstOrDefault(t => t.IsDeleted == 0 && t.Zoneid == surgePrice.Zoneid);

            if (existZone == null)
            {
                throw new DataValidationException("Zone name does not exist");
            }

            var exist = content.TabSurgeprice.FirstOrDefault(t => t.IsDelete == false && t.ZoneId == surgePrice.Zoneid);

            if (exist == null)
            {
                TabSurgeprice tabSurgeprice = new TabSurgeprice();
                tabSurgeprice.PeakType        = surgePrice.Peaktype;
                tabSurgeprice.StartTime       = surgePrice.Starttime;
                tabSurgeprice.ZoneId          = surgePrice.Zoneid;
                tabSurgeprice.EndTime         = surgePrice.Endtime;
                tabSurgeprice.SurgepriceType  = surgePrice.Surgepricetype;
                tabSurgeprice.SurgepriceValue = surgePrice.Surgepricevalue;
                tabSurgeprice.IsActive        = true;
                tabSurgeprice.UpdatedAt       = tabSurgeprice.CreatedAt = Extention.GetDateTime();
                tabSurgeprice.UpdatedBy       = tabSurgeprice.CreatedBy = loggedIn.UserName;
                content.TabSurgeprice.Add(tabSurgeprice);
                content.SaveChanges();
                return(true);
            }
            else
            {
                exist.PeakType        = surgePrice.Peaktype;
                exist.StartTime       = surgePrice.Starttime;
                exist.EndTime         = surgePrice.Endtime;
                exist.SurgepriceType  = surgePrice.Surgepricetype;
                exist.SurgepriceValue = surgePrice.Surgepricevalue;

                exist.UpdatedAt = Extention.GetDateTime();
                exist.UpdatedBy = loggedIn.UserName;
                content.TabSurgeprice.Update(exist);
                content.SaveChanges();
                return(true);
            }
        }
Beispiel #3
0
 public SurgePrice GetSurgePrice(TaxiAppzDBContext context, long zoneId)
 {
     try
     {
         SurgePrice surgePrice     = new SurgePrice();
         var        listSurgePrice = context.TabSurgeprice.FirstOrDefault(t => t.ZoneId == zoneId);
         if (listSurgePrice != null)
         {
             surgePrice.Id              = listSurgePrice.SurgepriceId;
             surgePrice.Starttime       = listSurgePrice.StartTime;
             surgePrice.Endtime         = listSurgePrice.EndTime;
             surgePrice.Peaktype        = listSurgePrice.PeakType;
             surgePrice.Surgepricetype  = listSurgePrice.SurgepriceType;
             surgePrice.Surgepricevalue = listSurgePrice.SurgepriceValue;
         }
         return(surgePrice != null ? surgePrice : null);
     }
     catch (Exception ex)
     {
         Extention.insertlog(ex.Message, "Admin", System.Reflection.MethodBase.GetCurrentMethod().Name, context);
         return(null);
     }
 }
Beispiel #4
0
 public override int GetHashCode()
 {
     return(Val.GetHashCode() ^ Type.GetHashCode() ^
            SurgePrice.GetHashCode() ^ StaminaPrice.GetHashCode() ^
            Used.GetHashCode());
 }