Exemplo n.º 1
0
 public static LoggedInUserModel FromDomainModel(User user)
 {
     if (user == null || user.Id == 0) {
         return new LoggedInUserModel { IsAuthenticated = false, Name = string.Empty };
     }
     return new LoggedInUserModel { IsAuthenticated = true, Name = user.Name };
 }
Exemplo n.º 2
0
 public void UpdateUser(User user)
 {
     var toUpdate = GetUser(user.Id);
     toUpdate.Name = user.Name;
     toUpdate.Role = user.Role;
     toUpdate.Description = user.Description;
     toUpdate.ParentId = user.ParentId;
     userRepo.SaveChanges();
 }
Exemplo n.º 3
0
 public static UserModel FromDomainModel(User user)
 {
     return new UserModel {
         Id = user.Id,
         Name = user.Name,
         Email = user.Email,
         Role = user.Role,
         Description = user.Description,
         ParentId = user.ParentId,
         RegionId = user.UserRegionMaps != null && user.UserRegionMaps.Any() ? user.UserRegionMaps.First().RegionId : 0
     };
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="role">Initial value of the Role property.</param>
 /// <param name="parentId">Initial value of the ParentId property.</param>
 /// <param name="objectInfo">Initial value of the ObjectInfo property.</param>
 public static User CreateUser(global::System.Int32 id, global::System.String name, global::System.String email, global::System.String role, global::System.Int32 parentId, ObjectInfo objectInfo)
 {
     User user = new User();
     user.Id = id;
     user.Name = name;
     user.Email = email;
     user.Role = role;
     user.ParentId = parentId;
     user.ObjectInfo = StructuralObject.VerifyComplexObjectIsNotNull(objectInfo, "ObjectInfo");
     return user;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
Exemplo n.º 6
0
 public static string SaveRetailFile(HttpPostedFileBase httpPostedFileBase, Dealer dealer, Month month, User csm)
 {
     var directory = "/File/" + csm.Name;
     if (string.IsNullOrEmpty(httpPostedFileBase.FileName))
         return string.Empty;
     var ext = httpPostedFileBase.FileName.Split('.').LastOrDefault() ?? "";
     var absoluteDirectory = ConvertToAbsolute(directory);
     if (!Directory.Exists(absoluteDirectory))
         Directory.CreateDirectory(absoluteDirectory);
     var temppath = string.Format("{0}/{1}", directory, string.Format("{0}.{1}", Guid.NewGuid(), ext));
     var absolutepath = ConvertToAbsolute(temppath);
     httpPostedFileBase.SaveAs(absolutepath);
     return temppath;
 }