public HttpResponseMessage Add(DoctorViewModel doctorViewModel)
        {
            try
            {
                var user = UserMatching.IsUserMatch();
                if (user == null)
                {
                    responseDoctor.UnAuthorized();
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseDoctor, contentType));
                }
                doctorViewModel.IsInternalCreated = user.IsInternalUser;
                doctorViewModel.CreatedBy         = user.Id;
                SqlParameter[] sqlParameters;
                string         parameter = SQLParameters.GetParameters <DoctorViewModel>(doctorViewModel);
                sqlParameters = SQLParameters.GetSQLParameters <DoctorViewModel>(doctorViewModel, "Add").ToArray();
                var result = unitOfWork.GetRepositoryInstance <object>().WriteStoredProcedure("Doctor_Detail " + parameter, sqlParameters);
                if (result >= 1)
                {
                    responseDoctor.Success((new JavaScriptSerializer()).Serialize(result));
                }
                else
                {
                    responseDoctor.Failed((new JavaScriptSerializer()).Serialize(doctorViewModel), "Failed to add doctor detail, please try again");
                }

                return(Request.CreateResponse(HttpStatusCode.Accepted, responseDoctor, contentType));
            }
            catch (Exception exception)
            {
                responseDoctor.Exception(exception.Message);
                return(Request.CreateResponse(HttpStatusCode.Conflict, responseDoctor, contentType));
            }
        }
        public HttpResponseMessage GetById(int id)
        {
            try
            {
                var doctorViewModel = new DoctorViewModel();
                doctorViewModel.Id = id;
                if (UserMatching.IsUserMatch() == null)
                {
                    responseDoctor.UnAuthorized();
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseDoctor, contentType));
                }

                SqlParameter[] sqlParameters;
                string         parameter = SQLParameters.GetParameters <DoctorViewModel>(doctorViewModel);
                sqlParameters = SQLParameters.GetSQLParameters <DoctorViewModel>(doctorViewModel, "GetById").ToArray();
                var doctor = unitOfWork.GetRepositoryInstance <DoctorViewModel>().ReadStoredProcedure("Doctor_Detail " + parameter, sqlParameters).ToList();
                responseDoctor.Success((new JavaScriptSerializer()).Serialize(doctor));
                return(Request.CreateResponse(HttpStatusCode.Accepted, responseDoctor, contentType));
            }
            catch (Exception exception)
            {
                responseDoctor.Exception(exception.Message);
                return(Request.CreateResponse(HttpStatusCode.Conflict, responseDoctor, contentType));
            }
        }
Example #3
0
 public HttpResponseMessage Update(SpecializationViewModel specializationViewModel)
 {
     try
     {
         var user = UserMatching.IsUserMatch();
         if (user == null)
         {
             responseSpecialization.UnAuthorized();
             return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseSpecialization, contentType));
         }
         specializationViewModel.UpdatedBy         = user.Id;
         specializationViewModel.IsInternalCreated = user.IsInternalUser;
         SqlParameter[] sqlParameters;
         string         parameter = SQLParameters.GetParameters <SpecializationViewModel>(specializationViewModel);
         sqlParameters = SQLParameters.GetSQLParameters <SpecializationViewModel>(specializationViewModel, "Update").ToArray();
         var specialization = unitOfWork.GetRepositoryInstance <object>().WriteStoredProcedure("Specialization_Detail " + parameter, sqlParameters);
         responseSpecialization.Success((new JavaScriptSerializer()).Serialize(specializationViewModel));
         return(Request.CreateResponse(HttpStatusCode.Accepted, responseSpecialization, contentType));
     }
     catch (Exception exception)
     {
         responseSpecialization.Exception(exception.Message);
         return(Request.CreateResponse(HttpStatusCode.Conflict, responseSpecialization, contentType));
     }
 }
Example #4
0
 public HttpResponseMessage Add([FromBody] SpecializationViewModel specializationViewModel)
 {
     try
     {
         var user = UserMatching.IsUserMatch();
         if (user == null)
         {
             responseSpecialization.UnAuthorized();
             return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseSpecialization, contentType));
         }
         specializationViewModel.CreatedBy         = user.Id;
         specializationViewModel.IsInternalCreated = user.IsInternalUser;
         SqlParameter[] sqlParameters;
         string         parameter = SQLParameters.GetParameters <SpecializationViewModel>(specializationViewModel);
         sqlParameters = SQLParameters.GetSQLParameters <SpecializationViewModel>(specializationViewModel, "GetByName").ToArray();
         var specialization = unitOfWork.GetRepositoryInstance <SpecializationViewModel>().ReadStoredProcedure("Specialization_Detail " + parameter, sqlParameters).ToList();
         if (specialization.Count > 0)
         {
             sqlParameters = SQLParameters.GetSQLParameters <SpecializationViewModel>(specializationViewModel, "GetByName").ToArray();
             responseSpecialization.Failed((new JavaScriptSerializer()).Serialize(specializationViewModel), "Specialization already exist");
             return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, responseSpecialization, contentType));
         }
         else
         {
             sqlParameters = SQLParameters.GetSQLParameters <SpecializationViewModel>(specializationViewModel, "Add").ToArray();
             var result = unitOfWork.GetRepositoryInstance <object>().WriteStoredProcedure("Specialization_Detail " + parameter, sqlParameters);
             if (result >= 1)
             {
                 responseSpecialization.Success((new JavaScriptSerializer()).Serialize(specializationViewModel));
                 return(Request.CreateResponse(HttpStatusCode.Created, responseSpecialization, contentType));
             }
             else
             {
                 responseSpecialization.Failed((new JavaScriptSerializer()).Serialize(specializationViewModel), "Failed to create new specialization, try again");
                 return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, responseSpecialization, contentType));
             }
         }
     }
     catch (Exception exception)
     {
         responseSpecialization.Exception(exception.Message);
         return(Request.CreateResponse(HttpStatusCode.Conflict, responseSpecialization, contentType));
     }
 }
Example #5
0
        public HttpResponseMessage GetAll()
        {
            try
            {
                var specializationViewModel = new SpecializationViewModel();
                if (UserMatching.IsUserMatch() == null)//specializationViewModel.UserName, specializationViewModel.Password))
                {
                    responseSpecialization.UnAuthorized();
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseSpecialization, contentType));
                }

                SqlParameter[] sqlParameters;
                string         parameter = SQLParameters.GetParameters <SpecializationViewModel>(specializationViewModel);
                sqlParameters = SQLParameters.GetSQLParameters <SpecializationViewModel>(specializationViewModel, "GetAll").ToArray();
                var specialization = unitOfWork.GetRepositoryInstance <SpecializationViewModel>().ReadStoredProcedure("Specialization_Detail " + parameter, sqlParameters).ToList();
                responseSpecialization.Success((new JavaScriptSerializer()).Serialize(specialization));
                return(Request.CreateResponse(HttpStatusCode.Accepted, responseSpecialization, contentType));
            }
            catch (Exception exception)
            {
                responseSpecialization.Exception(exception.Message);
                return(Request.CreateResponse(HttpStatusCode.Conflict, responseSpecialization, contentType));
            }
        }