Пример #1
0
        public ActionResult <ItemResponse <int> > Create(AppointmentAddRequest model)
        {
            ObjectResult result = null;

            try
            {
                int userId = _authService.GetCurrentUserId();

                int id = _service.Add(model, userId);
                ItemResponse <int> response = new ItemResponse <int>()
                {
                    Item = id
                };

                result = Created201(response);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                ErrorResponse response = new ErrorResponse(ex.Message);

                result = StatusCode(500, response);
            }

            return(result);
        }
Пример #2
0
 private static void ColSeekerAddParams(AppointmentAddRequest model, SqlParameterCollection col, int userId)
 {
     col.AddWithValue("@providerId", model.ProviderId);
     col.AddWithValue("@seekerId", userId);
     col.AddWithValue("@startTime", model.StartTime);
     col.AddWithValue("@endTime", model.EndTime);
     col.AddWithValue("@price", model.Price);
     col.AddWithValue("@isConfirmed", model.IsConfirmed);
     col.AddWithValue("@isCanceled", model.IsCancelled);
     col.AddWithValue("@CancellationReason", model.CancellationReason);
 }
Пример #3
0
        public HttpResponseMessage Post(AppointmentAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            _svc.Post(model);
            SuccessResponse response = new SuccessResponse();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #4
0
 public void PostType(AppointmentAddRequest model)
 {
     _prov.ExecuteNonQuery("Appointment_Insert"
                           , inputParamMapper : delegate(SqlParameterCollection paramCollection)
     {
         paramCollection.AddWithValue("@Name", model.Name);
         paramCollection.AddWithValue("@PersonId", model.PersonId);
         paramCollection.AddWithValue("@Description", model.Description);
         paramCollection.AddWithValue("@ProgramId", model.ProgramId);
         paramCollection.AddWithValue("@AppointmentTypeId", model.AppointmentTypeId);
         paramCollection.AddWithValue("@CriteriaStartDate", model.CriteriaStartDate);
         paramCollection.AddWithValue("@CriteriaEndDate", model.CriteriaEndDate);
     });
 }
Пример #5
0
        public int Add(AppointmentAddRequest model, int userId)
        {
            int id = 0;

            string procName = "[dbo].[Appointments_Insert_V2]";

            _data.ExecuteNonQuery(procName, inputParamMapper : delegate(SqlParameterCollection col)
            {
                ColSeekerAddParams(model, col, userId);


                SqlParameter idOut = new SqlParameter("@Id", SqlDbType.Int);
                idOut.Direction    = ParameterDirection.Output;

                col.Add(idOut);
            }, returnParameters : delegate(SqlParameterCollection returnCollection)
            {
                object oId = returnCollection["@Id"].Value;
                int.TryParse(oId.ToString(), out id);
            });
            return(id);
        }
Пример #6
0
        public void Post(AppointmentAddRequest model)
        {
            using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ViaDB"].ConnectionString))
            {
                con.Open();
                var cmd = con.CreateCommand();
                cmd.CommandText = "dbo.Appointments_Insert";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Name", model.Name);
                cmd.Parameters.AddWithValue("@Phone", model.Phone);
                cmd.Parameters.AddWithValue("@Email", model.Email);
                cmd.Parameters.AddWithValue("@Address", model.Address);
                cmd.Parameters.AddWithValue("@Date", model.Date);
                cmd.Parameters.AddWithValue("@Notes", model.Notes);
                cmd.Parameters.AddWithValue("@Device", model.Device);
                cmd.Parameters.AddWithValue("@Repair", model.Repair);
                cmd.Parameters.AddWithValue("@Total", model.Total);

                cmd.ExecuteNonQuery();
            }
        }
Пример #7
0
 public AppointmentAddResponse AddAppointment(AppointmentAddRequest query)
 {
     return(SubmitRequest <AppointmentAddResponse>(query));
 }