public void Setup() { _dataAccess = new Mock<IDataAccess>(); _dataAccess.Setup(m => m.Users()).Returns(new List<User> { new User() }); _dataAccess.Setup(m => m.Get(It.IsAny<int>())).Returns(new User()); _userService = new UserService(_dataAccess.Object); }
public WcfModel GetUserByNameAndPsd(string username, string password, string mac) { try { UserService userService = new UserService(); User item = new User(); item.UserName = username; item.Password = password; var user = userService.GetUserList(item); string ping = null; if (!String.IsNullOrEmpty(mac)) { ping = Security.GetPing(user.First().ID.ToString() + mac); userService.UpdateUserPing(user.First().ID, ping); } var data = from o in user select new { ID = o.ID.ToString(), Money = o.Money, Tags = o.Tags, Ping = ping, }; model.Data = JsonConvert.SerializeObject(data); model.Code = WcfStatus.QuerySuccessful; } catch (RepeatedException e) { model.Code = WcfStatus.QueryError; model.ErrorMsg = e.OutMsg; } catch (DataNotFoundException e) { model.Code = WcfStatus.QueryNoData; model.ErrorMsg = e.Message; } return model; }
static void Main(string[] args) { Console.WriteLine("Enter Username"); Console.WriteLine("(Tester0 == Systemerror)"); Console.WriteLine("(enter nothing == Usererror)"); string username = Console.ReadLine(); UserService srv = new UserService(); ServiceResponse<User> result = srv.GetUser(new ServiceRequest<string>() { Value = username }); if (result.Result == ServiceResult.Succeeded) { Console.WriteLine("Service Call Succeeded"); Console.WriteLine(result.Value); } if (result.Result == ServiceResult.Failed) { Console.WriteLine("Service Call Failed"); Console.WriteLine(result.ErrorCodes.ToString()); } if (result.Result == ServiceResult.Fatal) { Console.WriteLine("Service Call Fatal Error"); Console.WriteLine(result.Exception.ToString()); } Console.ReadLine(); }
public ActionResult CreateSuggestion(suggestion suggestion) { IUser user = new UserService(); user u = user.show(Session["cuser"].ToString()); suggestionService.SendMail(u.email); suggestionService.SendSMS(u.tel, "TnTroc : New Suggestion ! "); suggestion.status = false; suggestionService.AddSuggestion(suggestion); return RedirectToAction("SuggestionByUser"); }
public WcfModel AddUser(User user) { try { UserService userService = new UserService(); userService.AddUser(user); model.Code = WcfStatus.AddSuccessful; } catch (Exception e) { model.Code = WcfStatus.AddFailed; model.ErrorMsg = e.Message; } return model; }
public ActionResult Create([Bind(Include="id,description,name,periode")] eve eve) { IUser service = null; service = new Service.UserService(); if (ModelState.IsValid) { db.eves.Add(eve); db.SaveChanges(); System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); foreach (var item1 in service.getUsers()) { mail.To.Add(item1.email); } mail.From = new MailAddress("*****@*****.**","tntroc"); mail.Subject = "New Event Notification"; string Body = eve.description; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "50020892");// Enter seders User name and password smtp.EnableSsl = true; smtp.Send(mail); return RedirectToAction("Index"); } return View(eve); }
public WcfModel GetUserByPing(string ping) { try { UserService userService = new UserService(); var user = userService.GetUserByPing(ping); var data = from o in user select new { ID = o.ID.ToString(), Money = o.Money, Tags = o.Tags, }; model.Data = JsonConvert.SerializeObject(data); model.Code = WcfStatus.QuerySuccessful; } catch (RepeatedException e) { model.Code = WcfStatus.QueryError; model.ErrorMsg = e.OutMsg; } catch (DataNotFoundException e) { model.Code = WcfStatus.QueryNoData; model.ErrorMsg = e.Message; } return model; }
private void SetFields() { UserService userService = new UserService(); List<Roles> roles = userService.GetUserRoleByUid(UserContext.Instance.CurrentUser.Uid); bool bRLRY = roles.Exists(r => r.RolesName.Trim() == "录入人员"); bool bJCRY = roles.Exists(r => r.RolesName.Trim() == "检测人员"); foreach(Control c in Page.Form.Controls){ if(c is TextBox){ TextBox tb = (TextBox) c; if(writeFilds.Contains(tb.ID) && bRLRY){ tb.ReadOnly = false; } else if(!writeFilds.Contains(tb.ID) && bJCRY){ tb.ReadOnly = false; } else{ tb.ReadOnly = true; } } } }
public ActionResult Follow(string current , string follow) { IUser service = null; service = new UserService(); user currentu = service.show(((string)Session["session"]).ToLower()); user followu = service.show(follow); service.follow(currentu, followu, 1); return View(); }
// GET: offre1 public ActionResult Index(string id) { Home home = new Home(); if (id !=null) { Session["peerid"] = id;} if (Session["session"] == null) { return RedirectToAction("Index", "User"); } ViewBag.EmployeeName = Session["peerid"]; ViewBag.Company = Session["session"]; ViewBag.Company = Session["session"]; home.offers = offreService.GetOffres().ToList(); //Followers IAdService service = null; service = new AdService(); var user = new user(); var user1 = new user(); var user2 = new user(); var user3 = new user(); user.username = "******"; user1.username = "******"; user2.username = "******"; user3.username = "******"; var follower1 = new follower(user1, 10); var follower2 = new follower(user2, 5); var follower3 = new follower(user3, 7); user.followers.Add(follower1); user.followers.Add(follower2); user.followers.Add(follower3); offre offre1 = new offre(); offre offre2 = new offre(); offre offre3 = new offre(); photo photo1 = new photo(); photo photo2 = new photo(); photo photo3 = new photo(); offre1.description = "description offre 1 "; offre2.description = "description offre 2 description offre 2 description offre 2 description offre 2 description offre 2 "; offre3.description = "description offre 3 "; offre1.name = "offre1"; offre2.name = "offre2"; offre3.name = "offre3"; product product1 = new product(); product1.name = "test1"; product1.description = "test1_discription"; product1.offre = offre1; product1.photo = photo1; product1.photo.link = "~/Content/images/products/product01.png"; product product2 = new product(); //product1.photo.link.ToString(); product2.name = "test2"; product2.description = "test2_discription"; product2.offre = offre2; product2.photo = photo2; product2.photo.link = "~/Content/images/products/product02.png"; product product3 = new product(); product3.name = "test3"; product3.description = "test3_discription"; product3.offre = offre3; product3.photo = photo3; product3.photo.link = "~/Content/images/products/product03.png"; user1.products.Add(product1); user2.products.Add(product2); user3.products.Add(product3); //user.followers.Add(follower1); IUser u1 = new UserService(); user userc = u1.show(((string)Session["session"]).ToLower()); IProductService prod = new ProductService(); userc.products=prod.FindProductsByUser(((string)Session["session"]).ToLower()).ToList(); IFollowerService f = new FollowerService(); userc.followers= f.GetFollowers(userc.username).ToList(); ViewBag.followers = new SelectList(userc.followers, "FollowerId", "Rate"); home.user = user; return View(home); }
public WcfModel UpdateUserTag(string id, string tagID) { try { UserService userService = new UserService(); userService.UpdateUserTag(DataConvert.ToObjectId(id), DataConvert.ToObjectId(tagID)); model.Code = WcfStatus.UpdateSuccessful; } catch (InvalidIdException e) { model.Code = WcfStatus.ParameterError; model.ErrorMsg = e.Message; } return model; }
/// <summary> /// 判断用户名是否存在 /// </summary> /// <returns>存在返回0,不存在返回1</returns> public WcfModel IsUserNameExist(string username) { try { UserService userService = new UserService(); User item = new User(); item.UserName = username; var user = userService.GetUserList(item); model.Code = WcfStatus.QuerySuccessful; model.Data = "true"; } catch { model.Code = WcfStatus.QuerySuccessful; model.Data = "false"; } return model; }