public string InsertUser(User pUser) { string result = string.Empty; User _user = null; if (pUser != null) { pUser.UserId = pUser.UserId.ToLower(); _user = (from p in context.User where p.UserId == pUser.UserId select p).FirstOrDefault(); if (_user == null) { _user = (from p in context.User where p.UserId == pUser.UserId.ToUpper() select p).FirstOrDefault(); } if (_user == null) { if (!string.IsNullOrEmpty(pUser.Password) && (pUser.Type == ConstantsVar.Patient || pUser.Type == ConstantsVar.Therapist || pUser.Type == ConstantsVar.Support)) { AddUser luser = new AddUser(); luser.secretkey = ConfigVars.NewInstance.secretkey; luser.username = pUser.UserId; luser.fn = pUser.Name; luser.ln = pUser.Name; luser.password = pUser.Password; VSeeHelper lhelper = new VSeeHelper(); var resUser = lhelper.AddUser(luser); if (resUser != null && resUser["status"] == "success") { pUser.Vseeid = "onedirect+" + pUser.UserId.ToLower(); context.User.Add(pUser); context.SaveChanges(); result = "success"; } } else { context.User.Add(pUser); context.SaveChanges(); result = "success"; } //Prabhu } else { result = "Username already exists"; } } return(result); }
public string UpdateUser(User pUser) { string result = string.Empty; var _user = (from p in context.User where p.UserId == pUser.UserId select p).FirstOrDefault(); if (_user != null) { dynamic resUser = null; VSeeHelper lhelper = new VSeeHelper(); AddUser luser = new AddUser(); luser.secretkey = ConfigVars.NewInstance.secretkey; luser.username = pUser.UserId; luser.fn = pUser.Name; luser.ln = pUser.Name; luser.password = pUser.Password; if (!string.IsNullOrEmpty(pUser.Password) && !string.IsNullOrEmpty(pUser.Vseeid) && (pUser.Type == ConstantsVar.Patient || pUser.Type == ConstantsVar.Therapist || pUser.Type == ConstantsVar.Support)) { resUser = lhelper.UpdateUser(luser); } else if (!string.IsNullOrEmpty(pUser.Password) && string.IsNullOrEmpty(pUser.Vseeid) && (pUser.Type == ConstantsVar.Patient || pUser.Type == ConstantsVar.Therapist || pUser.Type == ConstantsVar.Support)) { resUser = lhelper.AddUser(luser); } if (resUser != null && resUser["status"] == "success") { _user.Vseeid = "onedirect+" + pUser.UserId.ToLower(); } _user.Name = pUser.Name; _user.Email = pUser.Email; _user.Address = pUser.Address; _user.Phone = pUser.Phone; _user.Password = pUser.Password; _user.Type = pUser.Type; _user.Npi = pUser.Npi; _user.EncryptPasswrod = pUser.EncryptPasswrod; context.Entry(_user).State = EntityState.Modified; context.SaveChanges(); result = "success"; } return(result); }