public bool EditZoneType(ZoneTypeRelation zoneTypeRelation, TaxiAppzDBContext context, LoggedInUser loggedInUser) { var serviceExist = context.TabZone.FirstOrDefault(t => t.IsDeleted == 0 && t.Zoneid == zoneTypeRelation.Zoneid); if (serviceExist == null) { throw new DataValidationException($"Zone does not already exists."); } var typeExist = context.TabTypes.FirstOrDefault(t => t.IsDeleted == 0 && t.Typeid == zoneTypeRelation.Typeid); if (typeExist == null) { throw new DataValidationException($"Vechile type does not already exists."); } var zonetypeedit = context.TabZonetypeRelationship.Where(z => z.Zoneid == zoneTypeRelation.Zoneid && z.Typeid == zoneTypeRelation.Typeid).FirstOrDefault(); if (zonetypeedit != null) { zonetypeedit.Zoneid = zoneTypeRelation.Zoneid; zonetypeedit.Typeid = zoneTypeRelation.Typeid; zonetypeedit.Paymentmode = zoneTypeRelation.Paymentmode; zonetypeedit.Showbill = zoneTypeRelation.Showbill.ToUpper() == "YES" ? true : false; zonetypeedit.IsActive = 1; context.TabZonetypeRelationship.Update(zonetypeedit); context.SaveChanges(); return(true); } return(false); }
public bool AddZoneType(long zoneid, ZoneTypeRelation zoneTypeRelation, TaxiAppzDBContext context, LoggedInUser loggedInUser) { var serviceExist = context.TabZone.FirstOrDefault(t => t.IsDeleted == 0 && t.Zoneid == zoneTypeRelation.Zoneid); if (serviceExist == null) { throw new DataValidationException($"Zone does not already exists."); } var typeExist = context.TabTypes.FirstOrDefault(t => t.IsDeleted == 0 && t.Typeid == zoneTypeRelation.Typeid); if (typeExist == null) { throw new DataValidationException($"Vechile type does not already exists."); } var isrelationshipexist = context.TabZonetypeRelationship.Any(z => z.Zoneid == zoneid && z.IsDelete == 0); TabZonetypeRelationship tabZonetypeRelationship = new TabZonetypeRelationship(); tabZonetypeRelationship.Zoneid = zoneTypeRelation.Zoneid; tabZonetypeRelationship.Typeid = zoneTypeRelation.Typeid; tabZonetypeRelationship.Paymentmode = zoneTypeRelation.Paymentmode; tabZonetypeRelationship.Showbill = zoneTypeRelation.Showbill.ToUpper() == "YES" ? true : false; tabZonetypeRelationship.IsActive = 1; tabZonetypeRelationship.IsDefault = isrelationshipexist ? 0 : 1; context.TabZonetypeRelationship.Add(tabZonetypeRelationship); context.SaveChanges(); return(true); }
public ZoneTypeRelation GetZoneTypebyid(long zoneid, long zonetypeid, TaxiAppzDBContext context) { try { ZoneTypeRelation zoneTypeRelation = new ZoneTypeRelation(); var zonetype = context.TabZonetypeRelationship.Include(t => t.Zoneid == zoneid && t.Typeid == zonetypeid).FirstOrDefault(); if (zonetype != null) { zoneTypeRelation.Typeid = zonetype.Typeid; zoneTypeRelation.Paymentmode = zonetype.Paymentmode; zoneTypeRelation.Showbill = zonetype.Showbill == true ? "YES" : "NO"; return(zoneTypeRelation != null ? zoneTypeRelation : null); } return(null); } catch (Exception ex) { Extention.insertlog(ex.Message.ToString(), "Admin", "GetZoneTypebyid", context); return(null); } }