Beispiel #1
0
        public HttpResponseMessage AddModalityProcedure(Entities.MstModalityProcedure objModalityProcedure)
        {
            try
            {
                var currentUser = from d in db.MstUsers
                                  where d.AspNetUserId == User.Identity.GetUserId()
                                  select d;

                var currentUserId = currentUser.FirstOrDefault().Id;

                Data.MstModalityProcedure newModalityProcedure = new Data.MstModalityProcedure
                {
                    ModalityId             = objModalityProcedure.ModalityId,
                    ModalityProcedure      = objModalityProcedure.ModalityProcedure,
                    ModalityResultTemplate = objModalityProcedure.ModalityResultTemplate,
                    DoctorId = currentUserId
                };

                db.MstModalityProcedures.InsertOnSubmit(newModalityProcedure);
                db.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Beispiel #2
0
        public HttpResponseMessage UpdateModalityProcedure(String id, Entities.MstModalityProcedure objModalityProcedure)
        {
            try
            {
                var modalityProcedure = from d in db.MstModalityProcedures
                                        where d.Id == Convert.ToInt32(id)
                                        select d;

                if (modalityProcedure.Any())
                {
                    var currentUser = from d in db.MstUsers
                                      where d.AspNetUserId == User.Identity.GetUserId()
                                      select d;

                    var currentUserId = currentUser.FirstOrDefault().Id;

                    var updateModalityProcedure = modalityProcedure.FirstOrDefault();
                    updateModalityProcedure.ModalityId             = objModalityProcedure.ModalityId;
                    updateModalityProcedure.ModalityProcedure      = objModalityProcedure.ModalityProcedure;
                    updateModalityProcedure.ModalityResultTemplate = objModalityProcedure.ModalityResultTemplate;
                    updateModalityProcedure.DoctorId = currentUserId;

                    db.SubmitChanges();

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }