public AddEditOperator GetDetail(AddEditOperator entity) { AddEditOperator obj = new AddEditOperator(); var a = (from p in objAlpha.OperatorMasters join detail in objAlpha.OperatorAddresses on p.Operator_ID equals detail.Operator_ID join C in objAlpha.CountryMasters on detail.Country equals C.Country join S in objAlpha.StateMasters on detail.State equals S.State join CI in objAlpha.CityMasters on detail.City equals CI.City where p.Operator_ID == entity.UserId select new { p.User_Name, p.User_Password, p.Initial, p.Name, p.DOB, p.Gender, p.Phone, p.Mobile, p.Email_ID, p.Last_Login, detail.Address, detail.Pin_Code, detail.Country, detail.City, detail.State, C.Country_ID, S.State_ID, CI.City_ID }).SingleOrDefault(); if (a != null) { obj.UserName = a.User_Name; obj.Password = a.User_Password; obj.ConfirmPassword = a.User_Password; obj.Initials = a.Initial; obj.Name = a.Name; obj.DateOfBirth = Convert.ToDateTime(a.DOB); obj.Gender = a.Gender; obj.Phone = a.Phone; obj.Mobile = a.Mobile; obj.EmailId = a.Email_ID; obj.Address = a.Address; obj.PinCode = a.Pin_Code; obj.Country = a.Country; obj.State = a.State; obj.City = a.City; obj.CountryId = a.Country_ID; obj.StateId = a.State_ID; obj.CityId = a.City_ID; return(obj); } else { return(obj); } }
public int AddNewUser(AddEditOperator objNewUser) { if (objNewUser != null) { var CheckUser = (from check in objAlpha.OperatorMasters where check.User_Name == objNewUser.UserName select check).SingleOrDefault(); if (CheckUser == null) { OperatorMaster objMaster = new OperatorMaster(); objMaster.User_Name = objNewUser.UserName; objMaster.User_Password = objNewUser.Password; objMaster.Last_Login = DateTime.Now; objMaster.User_Status = objNewUser.Status; objMaster.Initial = objNewUser.Initials; objMaster.Name = objNewUser.Name; objMaster.DOB = objNewUser.DateOfBirth; objMaster.Gender = objNewUser.Gender; objMaster.Phone = objNewUser.Phone; objMaster.Mobile = objNewUser.Mobile; objMaster.Email_ID = objNewUser.EmailId; objAlpha.OperatorMasters.InsertOnSubmit(objMaster); objAlpha.SubmitChanges(); OperatorAddress objDetail = new OperatorAddress(); objDetail.Operator_ID = objMaster.Operator_ID; objDetail.Address = objNewUser.Address; objDetail.City = objNewUser.City; objDetail.State = objNewUser.State; objDetail.Country = objNewUser.Country; objDetail.Pin_Code = objNewUser.PinCode; objAlpha.OperatorAddresses.InsertOnSubmit(objDetail); objAlpha.SubmitChanges(); return(1); } else { return(0); } } else { //Update var a = (from b in objAlpha.OperatorMasters where b.Operator_ID == objNewUser.UserId select b).SingleOrDefault(); if (a != null) { OperatorMaster objMaster = new OperatorMaster(); objMaster.User_Name = objNewUser.UserName; objMaster.User_Password = objNewUser.Password; objMaster.Last_Login = DateTime.Now; objMaster.User_Status = objNewUser.Status; objMaster.Initial = objNewUser.Initials; objMaster.Name = objNewUser.Name; objMaster.DOB = objNewUser.DateOfBirth; objMaster.Gender = objNewUser.Gender; objMaster.Phone = objNewUser.Phone; objMaster.Mobile = objNewUser.Mobile; objMaster.Email_ID = objNewUser.EmailId; objAlpha.SubmitChanges(); OperatorAddress objDetail = new OperatorAddress(); objDetail.Operator_ID = objMaster.Operator_ID; objDetail.Address = objNewUser.Address; objDetail.City = objNewUser.City; objDetail.State = objNewUser.State; objDetail.Country = objNewUser.Country; objDetail.Pin_Code = objNewUser.PinCode; objAlpha.SubmitChanges(); return(2); } else { return(0); } } }