public ActionResult Index(DoctorPrescription doctorPrescription) { var user = Session["User"] as User; var rowId = db.DoctorPrescriptions.Count(); if (user != null && user.OccupationsId == 1 && user.ProfessionId == 3) { string patientName = doctorPrescription.PatientName; string patientAge = doctorPrescription.PatientAge; string visitedDate = DateTime.Today.ToString("dd/M/yyyy", CultureInfo.InvariantCulture); int? genderId = doctorPrescription.GenderId; int doctorId = user.Id; char[] charsToTrim = { '/', ' ', '-' }; string patientId = (rowId + 1) + "11" + (rowId + 1); DoctorPrescription prescription = new DoctorPrescription() { PatientId = patientId, PatientName = patientName, PatientAge = patientAge, VisitedDate = visitedDate, DoctorId = doctorId, GenderId = genderId }; db.DoctorPrescriptions.Add(prescription); var rowAffected = db.SaveChanges(); if (rowAffected > 0) { var id = db.DoctorPrescriptions.SingleOrDefault(c => c.PatientId == patientId); int prescriptionId = id.Id; return(RedirectToAction("AddDrugs", new { prescriptionId = prescriptionId })); } else { ViewBag.message = "Information Not Save . Please try again !!"; return(View()); } } return(null); }
public ActionResult Create([Bind(Include = "Id,Subject,Name,Email,Message")] MessageInfo messageinfo) { db.MessageInfos.Add(messageinfo); var rowAffected = db.SaveChanges(); if (rowAffected > 0) { ViewBag.message = "Send Message Successfully"; } else { ViewBag.message = "Send Message Failed"; } return(View()); }
public ActionResult UpdateUserApproval(int userId, bool value) { var check = db.Users.Any(c => c.Id == userId && c.UserApproval != value); if (check) { var Users = db.Users.Find(userId); Users.UserApproval = value; var rowAffected = db.SaveChanges(); if (rowAffected > 0) { return(Content("Update Complete")); } else { return(Content("Update Not Complete")); } } return(Content("Nothing To Update")); }
public ActionResult Create(User user, HttpPostedFileBase file) { if (user.OccupationsId == 1 && user.ProfessionId == 3) { User users = new User() { FirstName = user.FirstName, LastName = user.LastName, Address = user.Address, UserName = user.UserName, Email = user.Email, Password = user.Password, UserApproval = false, GenderId = user.GenderId, OccupationsId = user.OccupationsId, ProfessionId = user.ProfessionId, UserRole = "user" }; string message = UploadFile(user, file); if (message == "You have not specified a file.. !!!! Please try again ..") { ViewBag.message = message; } else if (message == "Upload Failed") { ViewBag.message = "Id Upload Failed !! Please try again ..."; } else { db.Users.Add(users); var rowAffected = db.SaveChanges(); if (rowAffected > 0) { ViewBag.message = "Account Create Successfull"; } else { ViewBag.message = "Account Create Failed"; } } } else { User users = new User() { FirstName = user.FirstName, LastName = user.LastName, Address = user.Address, UserName = user.UserName, Email = user.Email, Password = user.Password, UserApproval = true, GenderId = user.GenderId, OccupationsId = user.OccupationsId, ProfessionId = user.ProfessionId, UserRole = "user" }; db.Users.Add(users); var rowAffected = db.SaveChanges(); if (rowAffected > 0) { ViewBag.message = "Account Create Successfull"; } else { ViewBag.message = "Account Create Failed"; } } ViewBag.GenderId = new SelectList(db.Genders, "Id", "Name", user.GenderId); ViewBag.OccupationsId = new SelectList(db.Occupations, "Id", "Name", user.OccupationsId); ViewBag.ProfessionId = new SelectList(db.Professions, "Id", "Name", user.ProfessionId); //return RedirectToAction("Create"); return(View()); }
public string SetPersonalRating(string drugRating, int drugId, User user, SocialUser socialUser) { string message = ""; if (user != null) { string rating = drugRating; int userId = user.Id; int brandId = drugId; if (user.OccupationsId == 1) { var rate = db.DrugsRatings.SingleOrDefault(c => c.UserId == userId && c.BrandId == brandId); if (rate != null) { rate.ProfessionalRatting = Convert.ToInt32(rating); db.Entry(rate).State = EntityState.Modified; var rowAffected = db.SaveChanges(); if (rowAffected > 0) { message = "Save Successfull"; } } else { DrugsRating drugsRating = new DrugsRating() { UserId = userId, BrandId = brandId, ProfessionalRatting = Convert.ToInt32(rating) }; db.DrugsRatings.Add(drugsRating); var rowAffected = db.SaveChanges(); if (rowAffected > 0) { message = "Save Successfull"; } } } else if (user.OccupationsId == 2) { var rate = db.DrugsRatings.SingleOrDefault(c => c.UserId == userId && c.BrandId == brandId); if (rate != null) { rate.UserRatting = Convert.ToInt32(rating); db.Entry(rate).State = EntityState.Modified; var rowAffected = db.SaveChanges(); if (rowAffected > 0) { message = "Save Successfull"; } } else { DrugsRating drugsRating = new DrugsRating() { UserId = userId, BrandId = brandId, UserRatting = Convert.ToInt32(rating) }; db.DrugsRatings.Add(drugsRating); var rowAffected = db.SaveChanges(); if (rowAffected > 0) { message = "Save Successfull"; } } } } else if (socialUser != null) { string rating = drugRating; int socialUserId = socialUser.Id; int brandId = drugId; var rate = db.DrugsRatings.SingleOrDefault(c => c.SocialUserId == socialUserId && c.BrandId == brandId); if (rate != null) { rate.UserRatting = Convert.ToInt32(rating); db.Entry(rate).State = EntityState.Modified; var rowAffected = db.SaveChanges(); if (rowAffected > 0) { message = "Save Successfull"; } } else { DrugsRating drugsRating = new DrugsRating() { SocialUserId = socialUserId, BrandId = brandId, UserRatting = Convert.ToInt32(rating) }; db.DrugsRatings.Add(drugsRating); var rowAffected = db.SaveChanges(); if (rowAffected > 0) { message = "Save Successfull"; } } } return(message); }
public void ClickActivityForBrand(int?id) { if (session == null) { UserActivity userActivity = new UserActivity() { ActivityType = "Click", ActivityTime = DateTime.Today }; var drugBrand = db.DrugBrandInfos.Find(id); if (drugBrand != null) { userActivity.BrandId = drugBrand.Id; db.UserActivities.Add(userActivity); db.SaveChanges(); } } else { if (userType == "localUser") { UserActivity userActivity = new UserActivity() { ActivityType = "Click", ActivityTime = DateTime.Today, UserId = session.Id }; var drugBrand = db.DrugBrandInfos.Find(id); if (drugBrand != null) { userActivity.BrandId = drugBrand.Id; db.UserActivities.Add(userActivity); db.SaveChanges(); } } else { UserActivity userActivity = new UserActivity() { ActivityType = "Click", ActivityTime = DateTime.Today, SocialUserId = session.Id }; var drugBrand = db.DrugBrandInfos.Find(id); if (drugBrand != null) { userActivity.BrandId = drugBrand.Id; db.UserActivities.Add(userActivity); db.SaveChanges(); } } } }