public ActionResult Save(string CoreTeamLeaderId, string ProvinceId, string BranchName, string Phone, string EmailAddress, string StreetAddress, string City, string Suburb)
 {
     JazMax.Web.ViewModel.UserAccountView.CoreBranchView m = new ViewModel.UserAccountView.CoreBranchView()
     {
         BranchName       = BranchName,
         City             = City,
         CoreTeamLeaderId = Convert.ToInt32(CoreTeamLeaderId),
         EmailAddress     = EmailAddress,
         IsActive         = true,
         Phone            = Phone
     };
     JazMaxIdentityHelper.UserName = User.Identity.Name;
     if (JazMaxIdentityHelper.IsUserInRole("PA"))
     {
         m.ProvinceId = JazMaxIdentityHelper.GetPAUserInformation(User.Identity.Name).ProvinceId;
     }
     else
     {
         m.ProvinceId = Convert.ToInt32(ProvinceId);
     }
     m.StreetAddress = StreetAddress;
     m.Suburb        = Suburb;
     o.CreateNewBranch(m);
     return(Json(new { Result = "Success", Message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
 }
        public ActionResult UpdateBranch(string BranchId, string CoreTeamLeaderId, string ProvinceId, string BranchName, string Phone, string EmailAddress, string StreetAddress, string City, string Suburb)
        {
            try
            {
                JazMax.Web.ViewModel.UserAccountView.CoreBranchView m = new ViewModel.UserAccountView.CoreBranchView()
                {
                    BranchId   = Convert.ToInt16(BranchId),
                    BranchName = BranchName,
                    City       = City
                };
                if (CoreTeamLeaderId == null)
                {
                    //DO Nothing.
                    //Do not update the TeamLeaderID
                }
                else
                {
                    m.CoreTeamLeaderId = Convert.ToInt32(CoreTeamLeaderId);
                }
                m.EmailAddress = EmailAddress;
                m.IsActive     = true;
                m.Phone        = Phone;

                JazMaxIdentityHelper.UserName = User.Identity.Name;
                if (JazMaxIdentityHelper.IsUserInRole("PA"))
                {
                    m.ProvinceId = JazMaxIdentityHelper.GetPAUserInformation(User.Identity.Name).ProvinceId;
                }
                else
                {
                    m.ProvinceId = Convert.ToInt32(ProvinceId);
                }
                m.StreetAddress = StreetAddress;
                m.Suburb        = Suburb;
                o.Update(m, JazMaxIdentityHelper.GetCoreUserId());
                return(Json(new { Result = "Success", Message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { Result = "Error!", Message = "Branch could not be updated" }, JsonRequestBehavior.AllowGet));
            }
        }