public async Task <Profile> Create(string login, string password) { /*Создание пользователя с логином и паролем, получение количества пользователей и запись его в id+1*/ Profile newProfile = new Profile(); newProfile.login = login; newProfile.password = password; _context.Profiles.Add(newProfile); await _context.SaveChangesAsync(); return(newProfile); }
public async Task <IActionResult> Confirm([FromBody] OnlineQuery request) { #region FunctionBody bool existed = await _db.OnlineQueries.AnyAsync( a => a.QueryDate == request.QueryDate && a.IsDeleted == 0 && a.IsSchedule == 1); if (existed) { return(BadRequest(new ReturnErrorMessage(errortype: (int)ErrorTypes.Errors.ExistedTime, message: "This Time is exist by other user"))); } Doctor dcBase = await _db.Doctors.FirstOrDefaultAsync(a => a.Id == request.DoctorId); DoctorsInfo doctor = await _db.DoctorsInfos.FirstOrDefaultAsync(a => a.DoctorId == request.DoctorId); if ( doctor.WorkTimeFromDate > (int)request.QueryDate.DayOfWeek || doctor.WorkTimeToDate < (int)request.QueryDate.DayOfWeek ) { return(BadRequest(new ReturnErrorMessage(errortype: (int)ErrorTypes.Errors.NotAllowedTime, message: "This Time not registered by Doctor"))); } try { request.ServeDate = DateTime.Now; request.IsSchedule = 1; request.IsOnline = 1; request.Price = dcBase.Price; await _db.OnlineQueries.AddAsync(request); } catch (Exception x) { return(BadRequest(new ReturnErrorMessage(errortype: (int)ErrorTypes.Errors.Internal, message: x.Message, code: 500))); } await _db.SaveChangesAsync(); return(Ok(new ReturnMessage())); #endregion }