public Customers Add(Customers cust) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { session.Save(cust); transaction.Commit(); int id = cust.Customerid; return cust; } } }
public string Register(string EmailId, string Password, string AccountType, string Username,string Business_name, string ActivationStatus = "0") { UserRepository userrepo = new UserRepository(); try { logger.Error("Register"); if (!userrepo.IsUserExist(EmailId)) { Domain.Myfashion.Domain.User user = new Domain.Myfashion.Domain.User(); user.AccountType = AccountType; user.EmailId = EmailId; user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddDays(30); user.Password = Utility.MD5Hash(Password); user.PaymentStatus = "unpaid"; user.ProfileUrl = string.Empty; user.TimeZone = string.Empty; user.UserName = Username; user.UserStatus = 1; user.ActivationStatus = ActivationStatus; user.Company = Business_name; user.Id = Guid.NewGuid(); Guid PId =Guid.NewGuid(); user.PuId = PId.ToString()+Password; user.Company_id = Guid.NewGuid(); UserRepository.Add(user); try { Domain.Myfashion.Domain.Groups groups = AddGroupByUserId(user.Id); BusinessSettingRepository busnrepo = new BusinessSettingRepository(); BusinessSetting.AddBusinessSetting(user.Id, groups.Id, groups.GroupName); Team.AddTeamByGroupIdUserId(user.Id, user.EmailId, groups.Id); Account.AddAccountByUserId(user.Id, user.Company, user.Company_id, user.EmailId); UpdateTeam(EmailId, user.Id.ToString(), user.UserName); try { Domain.Myfashion.Domain.Customers objcust = new Customers(); objcust.Activekeywordcount = 200; objcust.Activeserpcampaignscount = 400; objcust.Firstname = Username; objcust.Allowedcampaignscount=200; objcust.Allowedkeywordcount = 2000; Customersrepository objcustrepo = new Customersrepository(); objcustrepo.Add(objcust); int id= objcustrepo.lastRecord(); Domain.Myfashion.Domain.Users objusers = new Users(); objcust.Customerid = id; objusers.Customers = objcust; objusers.Loginid = EmailId; objusers.Password = Password; objusers.Active = 1; objusers.Usertype = 0; objusers.Token = "bcd213199780916aa7525d3972fa7bb15c1d1d31e955cfca5f7524b35ee5ee27_a373c25b036ac7ff"; objusers.Addeddate = DateTime.Now; UsersRepository.addUsers(objusers); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } return new JavaScriptSerializer().Serialize(user); } else { return "Email Already Exists"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return "Something Went Wrong"; } }