Пример #1
0
 public sw.UserDetails getUserDetail(MembershipUser user)
 {
     sw.UserDetails organisation = (from u in swdb.UserDetails
                                    where u.UserId == (Guid)user.ProviderUserKey
                                    select u).FirstOrDefault();
     return(organisation);
 }
        private int getBranchID()
        {
            sw.UserDetails  organisation       = new sw.UserDetails();
            GetOrganisation objGetOrganisation = new GetOrganisation();
            MembershipUser  user = Membership.GetUser(User.Identity.Name);

            organisation = objGetOrganisation.getUserDetail(user);
            if (organisation == null)
            {
                return(0);
            }
            return(organisation.BranchID ?? 1);
        }
Пример #3
0
        public ActionResult EditProfile(ProfileEditModel row)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    sw.UserDetails userDetails = new sw.UserDetails();
                    userDetails              = row.userDetails;
                    userDetails.ModifiedBy   = User.Identity.Name;
                    userDetails.ModifiedDate = DateTime.Now;

                    var record = (from x in swdb.UserDetails where x.UserId == userDetails.UserId select x).FirstOrDefault();

                    if (record != null)
                    {
                        record.FirstName   = userDetails.FirstName;
                        record.LastName    = userDetails.LastName;
                        record.MiddleName  = userDetails.MiddleName;
                        record.PhoneNumber = userDetails.PhoneNumber;

                        swdb.SaveChanges();
                    }
                    else
                    {
                        swdb.UserDetails.Add(userDetails);
                        swdb.SaveChanges();
                    }



                    TempData["message"] = "Account details was saved successfully";
                    return(RedirectToAction("EditProfile", new { UserId = row.userDetails.UserId }));
                }
                else
                {
                    return(RedirectToAction("EditProfile", new { UserId = row.userDetails.UserId }));
                }
            }
            catch (Exception ex)
            {
                //ToDo: Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }