public MembershipCreateStatus bCreateUser(string CompanyName, string Username, string Password, string Email, string TaxCode, string Phone) { if (String.IsNullOrEmpty(CompanyName)) throw new ArgumentException("Value cannot be null or empty.", "CompanyName"); if (String.IsNullOrEmpty(Username)) throw new ArgumentException("Value cannot be null or empty.", "UserName"); if (String.IsNullOrEmpty(Email)) throw new ArgumentException("Value cannot be null or empty.", "Email"); if (String.IsNullOrEmpty(Password)) throw new ArgumentException("Value cannot be null or empty.", "Password"); MembershipCreateStatus status; var checkUser = from m in StoreDb.Webmasters where (m.Username == Username) select m; if (checkUser.Count() != 0) { status = MembershipCreateStatus.DuplicateUserName; return status; } var checkEmail = from m in StoreDb.Webmasters where (m.Email == Email) select m; if (checkEmail.Count() != 0) { status = MembershipCreateStatus.DuplicateEmail; return status; } Webmaster web = new Webmaster(); web.Username = Username; web.FirstName = CompanyName; web.CompanyName = CompanyName; web.Password = Password; web.Phone = Phone; web.Email = Email; web.Status = 0; web.DateJoin = DateTime.Now; web.AccountType = 1; //0 la personal account 1 la bussiness account web.TaxCode = TaxCode; string hash = MPHash.hash(Username + Password); web.VerifyCode = hash; StoreDb.Webmasters.AddObject(web); StoreDb.SaveChanges(); status = MembershipCreateStatus.Success; //Tao bang Earning tuong ung var checknow = StoreDb.Webmasters.Single(m => m.Username == Username); Earning e = new Earning(); e.Amount = 0; e.Currency = "VND"; e.WebmasterId = checknow.Id; e.Status = 0;//keep money StoreDb.Earnings.AddObject(e); StoreDb.SaveChanges(); //tao Role cho user nay string[] webmaster = new string[] { "Webmaster" }; string[] user = new string[] { Username }; MyRoleProvider role = new MyRoleProvider(); role.AddUsersToRoles(user, webmaster); //tao Setting table cho webmaster nay int webmt = StoreDb.Webmasters.Single(w => w.Username == Username).Id; Setting set = new Setting(); set.WebmasterId = webmt; set.Language = "EN";//default is EN StoreDb.Settings.AddObject(set); StoreDb.SaveChanges(); return status; }
/// <summary> /// Deprecated Method for adding a new object to the Webmasters EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToWebmasters(Webmaster webmaster) { base.AddObject("Webmasters", webmaster); }
/// <summary> /// Create a new Webmaster object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="username">Initial value of the Username property.</param> /// <param name="password">Initial value of the Password property.</param> public static Webmaster CreateWebmaster(global::System.Int32 id, global::System.String username, global::System.String password) { Webmaster webmaster = new Webmaster(); webmaster.Id = id; webmaster.Username = username; webmaster.Password = password; return webmaster; }
public ActionResult Index() { Webmaster webmaster = new Webmaster(); string loginId = User.Identity.Name; webmaster = StoreDb.Webmasters.Single(w => w.Username == loginId); var earning = StoreDb.Earnings.Single(e => e.WebmasterId == webmaster.Id); var website = from w in StoreDb.Websites where (w.Webmaster.Username == loginId) select w; int total411 = 0, total412 = 0, total413 = 0, total423 = 0, total42x = 0; int number411 =0, number412 = 0, number413 = 0 , number423 = 0, number42x = 0; List<WebsiteOrder> list = new List<WebsiteOrder>(); foreach (var x in website) { var oder = from o in StoreDb.WebsiteOrders where (o.WebsiteId == x.Id) orderby o.Date descending select o; foreach (var oo in oder) { //truong hop sau 30 ngay ma khong co problem if (oo.Date.AddDays(30) <= DateTime.Today && (oo.Status == 411 || oo.Status==412 ) && oo.MoneyStatus == 0)//order sau 30 ngay se tu dong them ket thuc { // va + tien cho webmaster oo.Status = 413; earning.Amount += oo.Amount; oo.MoneyStatus = 1;// money is available for webmaster oo.Date = oo.Date.AddDays(30); } //truong hop amin data validate the proof else if (oo.Status == 432 && oo.MoneyStatus == 0)//admin da validate the proof { oo.MoneyStatus = 1; earning.Amount += oo.Amount; } //count the account and number if (oo.Status == 411) { total411 += oo.Amount; number411++; } if (oo.Status == 412) { total412 += oo.Amount; number412++; } if (oo.Status == 413) { total413 += oo.Amount; number413++; } if (oo.Status == 423) { total423 += oo.Amount; number423++; } if (oo.Status == 421 || oo.Status == 422) { total42x += oo.Amount; number42x++; } list.Add(oo);// } } StoreDb.SaveChanges(); var earningNew = StoreDb.Earnings.Single(e => e.WebmasterId == webmaster.Id); ViewData["Earning"] = earningNew.Amount.ToString("n0"); ViewData["Currency"] = earning.Currency; TransactionLogViewModel.AddLog(loginId + " view the the Dashboard!", DateTime.Now); ViewData["total411"] = total411.ToString("n0"); ViewData["total412"] = total412.ToString("n0"); ViewData["total413"] = total413.ToString("n0"); ViewData["total423"] = total423.ToString("n0"); ViewData["total42x"] = total42x.ToString("n0"); ViewData["number411"] = number411; ViewData["number412"] = number412; ViewData["number413"] = number413; ViewData["number423"] = number423; ViewData["number42x"] = number42x; DateTime today = DateTime.Now.Date; DateTime FirtDateofMonth = HtmlHelpers.GetFirstDayOfMonth(DateTime.Today); DateTime LastDateofMonth = HtmlHelpers.GetTheLastDayOfMonth(DateTime.Today); DateTime FirstDateofLastMonth = HtmlHelpers.GetFirstDayOfMonth(today.AddMonths(-1)); DateTime LastDateofLastMonth = HtmlHelpers.GetTheLastDayOfMonth(today.AddMonths(-1)); DateTime FirstDateofYear = new DateTime(today.Year,1,1); DateTime LastDateofYear = new DateTime(today.Year,12,31); int todayearning = 0, yesterdayearning = 0, thismonthearning = 0, lastmonthearning = 0, thisyearearning = 0; foreach (var order in list) { if (order.Date == today) { todayearning += order.Amount; } if (order.Date == today.AddDays(-1)) { yesterdayearning += order.Amount; } if (order.Date >= FirtDateofMonth && order.Date <= LastDateofMonth) { thismonthearning += order.Amount; } if (order.Date >= FirstDateofLastMonth && order.Date <= LastDateofLastMonth) { lastmonthearning += order.Amount; } if (order.Date >= FirstDateofYear && order.Date <= LastDateofYear) { thisyearearning += order.Amount; } } ViewData["todayearning"] = todayearning.ToString("n0"); ViewData["yesterdayearning"] = yesterdayearning.ToString("n0"); ViewData["thismonthearning"] = thismonthearning.ToString("n0"); ViewData["lastmonthearning"] = lastmonthearning.ToString("n0"); ViewData["thisyearearning"] = thisyearearning.ToString("n0"); var phonenumber = StoreDb.Parameters.Single(s => s.Name == "PhoneNumber").Value; ViewData["phone"] = phonenumber.ToString(); return View(); }
public ActionResult postmessage(string message, string buyingcode, string[] webmaster, string[] moneypacific, string[] customer) { string userlogin = User.Identity.Name; var checkit1 = from c in db.BuyCustomers where c.BuyingId == userlogin select c; var checkit2 = from b in db.Webmasters where b.Username == userlogin select b; var checkit3 = from a in db.MPAdmins where a.Username == userlogin select a; if (!string.IsNullOrEmpty(message)) { Message p = new Message(); HttpPostedFileBase _file = Request.Files["file"]; if (_file.FileName != "") { if (_file.ContentLength > 0) { string filename = _file.FileName.Replace(" ", "_"); string filePath = Path.Combine(HttpContext.Server.MapPath("/Content/File/"), Path.GetFileName(filename)); _file.SaveAs(filePath); p.AttachFile = "/Content/File/" + _file.FileName.Replace(" ", "_"); } } p.Message1 = message; WebsiteOrder weborder = new WebsiteOrder(); Webmaster master = new Webmaster(); if (checkit1.Count() == 1) { p.Sender = 0; // Khach hang post //gui email cho webmaster. weborder = db.WebsiteOrders.Single(w => w.BuyingId == buyingcode); master = db.Webmasters.Single(w=>w.Id == weborder.Website.WebmasterId); //send email to webmaster string emailcontent = "Hi!<br/><br/>"; emailcontent += "The customer sent you the message.<br/><br/>"; emailcontent += "<b>Content:</b>"+message+"<br/><br/>"; emailcontent += "See you on Money Pacific. Com"; if (!string.IsNullOrEmpty(master.NotificationNewMessage)) { try { MPMail.SendMail(ConfigurationManager.AppSettings["MailSender"], master.NotificationNewMessage, "", "", "New Message from Customer", emailcontent); } catch (Exception e) { } } else try { MPMail.SendMail(ConfigurationManager.AppSettings["MailSender"], master.Email, "", "", "New Message from Customer", emailcontent); } catch (Exception e) { } } else if (checkit2.Count() == 1) { p.Sender = 1;// webmaster post } else if (checkit3.Count() == 1)//admin post { p.Sender = 2; } p.DateSend = DateTime.Now; p.UserId = buyingcode; p.IsClose = false; string postTo = ""; if (customer != null) { p.ToCustomer = true; postTo = buyingcode+" "; } else { p.ToCustomer = false; } if (webmaster != null) { p.ToWebmaster = true; postTo += master.Username + " "; } else p.ToWebmaster = false; if (moneypacific != null) { p.ToMPAdmin = true; postTo += "Money Pacific Admin"; } else p.ToMPAdmin = false; db.Messages.AddObject(p); db.SaveChanges(); TransactionLogViewModel.AddLog(userlogin +" has just posted the message to:"+postTo+" on Pacific Manager!", DateTime.Now); } return RedirectToAction("follow", new { id=buyingcode}); }
public ActionResult Index() { Webmaster webmaster = new Webmaster(); string loginId = User.Identity.Name; webmaster = StoreDb.Webmasters.Single(w => w.Username == loginId); var earning = StoreDb.Earnings.Single(e => e.WebmasterId == webmaster.Id); var website = from w in StoreDb.Websites where (w.Webmaster.Username == loginId) select w; List<WebsiteOrder> list = new List<WebsiteOrder>(); foreach (var x in website) { var oder = from o in StoreDb.WebsiteOrders where (o.WebsiteId == x.Id) orderby o.Date descending select o; foreach (var oo in oder) { if (oo.Date.AddDays(30) <= DateTime.Today && (oo.Status == 411 || oo.Status==412 ))//order sau 30 ngay se tu dong them ket thuc { // va + tien cho webmaster oo.Status = 413; earning.Amount += oo.Amount; oo.MoneyStatus = 1;// money is available for webmaster oo.Date = oo.Date.AddDays(30); } list.Add(oo); } } StoreDb.SaveChanges(); ViewData["AccountType"] = webmaster.AccountType; ViewData["Name"] = webmaster.Name; var earningNew = StoreDb.Earnings.Single(e => e.WebmasterId == webmaster.Id); ViewData["Earning"] = earningNew.Amount.ToString("n0"); ViewData["Currency"] = earning.Currency; AccountIndexViewModel model = new AccountIndexViewModel() { listOrder = list }; return View(model); }