Exemplo n.º 1
0
        public HttpResponseMessage UpsertDoctor(HttpRequestMessage request, tbHospital hospital)
        {
            string     result       = null;
            tbHospital UpdateEntity = null;

            if (hospital.Image != null)
            {
                result = iPhoto.uploadPhoto(hospital.Image);
            }
            else
            {
                result = null;
            }

            if (hospital.ID > 0)
            {
                if (hospital.Image == null)
                {
                    tbHospital hos = dbContext.tbHospitals.Where(a => a.IsDeleted != true && a.ID == hospital.ID).FirstOrDefault();
                    hospital.Photo = hos.Photo;
                }
                else
                {
                    hospital.Photo = result;
                }
                hospital.Image = null;
                UpdateEntity   = hospitalRepo.UpdatewithObj(hospital);
            }
            else
            {
                hospital.Photo      = result;
                hospital.Image      = null;
                hospital.IsDeleted  = false;
                hospital.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow);
                UpdateEntity        = hospitalRepo.AddWithGetObj(hospital);
            }

            return(request.CreateResponse <tbHospital>(HttpStatusCode.OK, UpdateEntity));
        }