/// <summary> /// Convert Member Object into Member Entity /// </summary> ///<param name="model">Member</param> ///<param name="MemberEntity">DataAccess.Member</param> ///<returns>DataAccess.Member</returns> public static DataAccess.Member ToEntity(this MemberViewModel model, DataAccess.Member entity) { if (entity.Id == 0) { entity.PersonId = model.PersonId; entity.MemberNo = model.MemberNo; entity.CreatedUserId = model.SessionUserId; } else { entity.UpdatedUserId = model.SessionUserId; entity.UpdatedTimestamp = DateTime.Now; } entity.Occupation = model.Occupation; entity.Company = model.Company; entity.WorkTelephone = model.WorkTelephone; entity.HomeTelephone = model.HomeTelephone; entity.EmmergencyContact1 = model.EmmergencyContact1; entity.EmmergencyContactNo1 = model.EmmergencyContactNo1; entity.EmmergencyContact2 = model.EmmergencyContact2; entity.EmmergencyContactNo2 = model.EmmergencyContactNo2; entity.MedicalAidNumber = model.MedicalAidNumber; entity.MedicalAidName = model.MedicalAidName; return(entity); }
public EditReturnModel InsertUser(string password, string email, bool gender, DateTime? birthday, string firstName, string lastName, string phone, string facebookid) { try { var userId = Guid.NewGuid(); //Check facebook Id var facebook = !string.IsNullOrEmpty(facebookid) && DataContext.Members.Any(m => m.FacebookId == facebookid); if (facebook) return new EditReturnModel {Message = "FAE", Result = false}; var member = new Member() { UserId = userId, Birthday = birthday, Password = Cryptography.CreateShaHash(new[] {password, userId.ToString()}), Gender = gender, Email = email, FirstName = firstName, LastName = lastName, Phone = phone, FacebookId = facebookid, IsLoked = false, RegisterDate = DateTime.UtcNow.AddHours(7), TypeAccount = 1 }; DataContext.Members.Add(member); var result = DataContext.SaveChanges(); return new EditReturnModel {Result = result > 0}; } catch (Exception exception) { return new EditReturnModel {Result = false, Message = exception.ToString()}; } }
public int SignUp(Member obj) { sqlDataAccess da = new sqlDataAccess(); if (obj.Username.Equals("")) { return(6); } else if (obj.Name.Equals("")) { return(2); } else if (obj.Password.Equals("")) { return(3); } else if (obj.Address.Equals("")) { return(4); } else if (obj.Phone.Equals("")) { return(5); } else { SqlCommand cmd1 = da.GetCommand("select * from login where userid = '" + obj.Username + "'"); cmd1.Connection.Open(); cmd1.ExecuteNonQuery(); SqlDataAdapter DAdap = new SqlDataAdapter(cmd1); DataTable dt = new DataTable(); DAdap.Fill(dt); if (dt.Rows.Count > 0) { cmd1.Connection.Close(); return(404); } else { SqlCommand cmd = da.GetCommand("insert into MemberTable (userid,name,address,phone,memberType) values ('" + obj.Username + "','" + obj.Name + "','" + obj.Address + "','" + obj.Phone + "','" + "inactive" + "')"); SqlCommand cmd2 = da.GetCommand("insert into Login (userid,password,keyid,status) values ('" + obj.Username + "','" + obj.Password + "','" + "" + "','" + "Inactive" + "')"); cmd.Connection.Open(); int i = cmd.ExecuteNonQuery(); if (i > 0) { cmd.Connection.Close(); cmd2.Connection.Open(); cmd2.ExecuteNonQuery(); cmd2.Connection.Close(); return(1); } else { cmd.Connection.Close(); return(0); } } } }