public void AddProfile(EmployeeProfile commandDto, string imgURL, string cartoonURL)
 {
     string user = System.Web.HttpContext.Current.User.Identity.Name;
     using (DbConnection conn = new SQLiteConnection(ConfigurationManager.ConnectionStrings["reedDirectory"].ConnectionString))
     {
         conn.Open();
         conn.Execute(
             "insert into EmployeeProfile (Department, FirstName, ImageUrl, LastName, Role, Tags, CreatedBy, CreatedOn, IsSuperUser, Extension, CartoonURL, WindowsIdentity, emailaddress, SeatingFloor, seatNo) values " +
             "(@Department, @FirstName, @ImageUrl, @LastName, @Role, @Tags, @CreatedBy, @CreatedOn, @IsSuperUser, @Extension, @CartoonURL, @WindowsIdentity, @emailAddress, @SeatingFloor, @seatNo)",
             new
                 {
                     Department = commandDto.Department,
                     FirstName = commandDto.FirstName.Replace("'","''"),
                     ImageUrl = imgURL,
                     LastName = commandDto.LastName.Replace("'", "''"),
                     Role = commandDto.Role,
                     Tags = !string.IsNullOrEmpty(commandDto.Tags) ? commandDto.Tags.Replace("'", "''"): "",
                     CreatedBy = user.Remove(0, 11),
                     CreatedOn = commandDto.CreatedOn,
                     IsSuperUser = false,
                     Extension = !string.IsNullOrEmpty(commandDto.Extension) ? commandDto.Extension.Replace("'", "''") : "",
                     CartoonURL = cartoonURL,
                     windowsIdentity = user,
                     emailAddress = commandDto.EmailAddress,
                     SeatingFloor = commandDto.SeatingFloor,
                     seatNo = commandDto.SeatNo
                 });
         conn.Close();
     }
 }
        public void UpdateProfile(EmployeeProfile commandDto, string imgURL, string cartoonURL)
        {
            string user = System.Web.HttpContext.Current.User.Identity.Name;
            using (DbConnection conn = new SQLiteConnection(ConfigurationManager.ConnectionStrings["reedDirectory"].ConnectionString))
            {
                conn.Open();
                conn.Execute("Update EmployeeProfile set Department=@Department, " +
                                                       "FirstName=@FirstName, " +
                                                       "ImageUrl=@ImageUrl, " +
                                                       "LastName=@LastName, " +
                                                       "Role=@Role, " +
                                                       "Tags=@Tags, " +
                                                       "UpdatedBy=@UpdatedBy, " +
                                                       "UpdatedOn=@UpdatedOn, " +
                                                       "Extension=@Extension, " +
                                                       "CartoonURL = @CartoonUrl, " +
                                                       "emailaddress = @emailaddress, " +
                                                       "SeatingFloor= @SeatingFloor, " +
                                                       "seatNo = @seatNo " +
                                                       "where ProfileId = @ProfileId",
                       new
                       {
                           Department = commandDto.Department,
                           FirstName = commandDto.FirstName.Replace("'", "''"),
                           ProfileId = commandDto.ProfileId,
                           ImageUrl = (string.IsNullOrEmpty(imgURL) ? commandDto.ImageUrl : imgURL),
                           LastName = commandDto.LastName.Replace("'", "''"),
                           Role = commandDto.Role,
                           Tags = !string.IsNullOrEmpty(commandDto.Tags) ? commandDto.Tags.Replace("'", "''") : "",
                           UpdatedBy = user,
                           UpdatedOn = DateTime.Now,
                           Extension = !string.IsNullOrEmpty(commandDto.Extension) ? commandDto.Extension.Replace("'", "''") : "",
                           CartoonUrl = (string.IsNullOrEmpty(cartoonURL) ? commandDto.CartoonUrl : cartoonURL),
                           emailaddress = commandDto.EmailAddress,
                           SeatingFloor = commandDto.SeatingFloor,
                           seatNo = commandDto.SeatNo
                       });

                conn.Close();
            }
        }
Example #3
0
        private static string LoadDefaultProfileImage(EmployeeProfile profile)
        {
            if (String.IsNullOrEmpty(profile.ImageUrl))
              {
            return "~/Content/images/profile-default.jpg";
              }

              return profile.ImageUrl;
        }