public bool CreatePromotion(PromotionBm bm, string getAppUserId) { var entityService = this.vehicleService.GetVehiceService(bm.Id); if (entityService == null) { return(false); } var isMember = entityService.ServiceMembers.Any(x => x.ApplicationUserId == getAppUserId); if (!isMember) { return(false); } foreach (var entityServicePromotion in entityService.Promotions) { entityServicePromotion.IsActive = false; } var promotion = new Promotion() { Type = BelongTo.VehicleService, Content = bm.Content, VehicleService = entityService, VehicleServiceId = entityService.Id, IsActive = true // just for now !!! }; entityService.Promotions.Add(promotion); return(this.commercialService.AddPromotion(promotion)); }
public JsonResult SavePromotion(PromotionBm bm) { if (bm.Id < 1) { this.Response.StatusCode = 400; return(this.Json(new ResultDto("400"), JsonRequestBehavior.AllowGet)); } ResultDto result = null; if (string.IsNullOrWhiteSpace(bm.Content)) { result = new ResultDto("empty"); return(this.Json(result, JsonRequestBehavior.AllowGet)); } bool isAdded = this.commercialManager.CreatePromotion(bm, this.GetAppUserId); if (!isAdded) { this.Response.StatusCode = 400; return(this.Json(new ResultDto("400"), JsonRequestBehavior.AllowGet)); } result = new ResultDto("success", true); return(this.Json(result, JsonRequestBehavior.AllowGet)); }