public async Task CreateAsync(string name, int length, SlopeDifficulty slopeDifficulty, Status status, string userId) { var resortId = this.resortService.GetResortIdOfUser(userId); var slope = new Slope { Name = name, Length = length, Difficulty = slopeDifficulty, Status = status, ResortId = resortId }; await this.db.Slopes.AddAsync(slope); db.SaveChanges(); }
public async Task <bool> EditAsync(string name, int length, SlopeDifficulty slopeDifficulty, Status status, int slopeId) { var slope = await this.GetSlopeAsync(slopeId); if (slope == null) { return(false); } slope.Name = name; slope.Length = length; slope.Difficulty = slopeDifficulty; slope.Status = status; db.Entry(slope).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); }