Esempio n. 1
0
        /// <summary>
        ///  Save Branch Details to DB
        /// </summary>
        /// <param name="branchInfoBO"></param>
        /// <param name="eMessage"></param>
        /// <returns></returns>

        public bool SaveBranchDetails(BranchInfoBO branchInfoBO, out string eMessage)
        {
            eMessage = "";
            var existingTypeBranchCode = db.Branch_Details.Where(t => t.BranchCode == branchInfoBO.BranchCode).SingleOrDefault();
            var existingTypeBranchName = db.Branch_Details.Where(t => t.BranchName == branchInfoBO.BranchName).SingleOrDefault();

            try
            {
                if (existingTypeBranchCode != null)
                {
                    eMessage = "Branch Code Is Already Exist...!!";
                    return(false);
                }

                if (existingTypeBranchName != null)
                {
                    eMessage = "Branch Name Is Already Exist..!!";
                    return(false);
                }

                if (branchInfoBO.Address.CountryID != 1)
                {
                    eMessage = "PAF Is Only Used For UK, So please Select a Country As a UK..!! ";
                    return(false);
                }
                var branchdetails = new Branch_Details();

                //branchdetails.AddressID = (int)branchInfoBO.AddressID;
                branchdetails.BranchCode     = branchInfoBO.BranchCode;
                branchdetails.BranchName     = branchInfoBO.BranchName;
                branchdetails.BranchTypeID   = (int)branchInfoBO.BranchTypeID;
                branchdetails.BranchStatusID = (int)branchInfoBO.BranchStatusID;
                branchdetails.Fax            = branchInfoBO.FaxNumber;
                branchdetails.Telephone      = branchInfoBO.TelephoneNumber;
                branchdetails.VATNumber      = branchInfoBO.VATnumber;
                branchdetails.Status         = false;
                db.Branch_Details.Add(branchdetails);
                if (branchInfoBO.Address.Postcode != null)
                {
                    branchdetails.AddressID = (int)addressBL.CheckAddress(branchInfoBO.Address);
                    branchInfoBO.AddressID  = branchInfoBO.Address.AddressID = branchdetails.AddressID;
                    if (branchInfoBO.Address.AddressID == 0)
                    {
                        eMessage = "AddressId Is Not Saved ";
                        return(false);
                    }
                }

                db.SaveChanges();
                eMessage = "Successfully Saved ";
                return(true);
            }
            catch (Exception e)
            {
                eMessage = e.Message;
                return(false);
            }
        }
Esempio n. 2
0
 private AddressBL addressBL = new AddressBL();      //Gets all the methods from "AddressBL"
 /// <summary>
 /// Save the User Details
 /// </summary>
 /// <param name="userViewModel"></param>
 public bool CreateUser(UserViewModel userViewModel, out string msg)
 {
     try
     {
         if (userViewModel.AddressViewModel.Postcode != null)
         {
             userViewModel.AddressID = (int)addressBL.CheckAddress(userViewModel.AddressViewModel);    //Assign a AddressID for Employee
             userViewModel.AddressViewModel.AddressID = userViewModel.AddressID;
             if (userViewModel.AddressViewModel.AddressID == 0)
             {
                 msg = "AddressID Is Not Saved!.....";
                 return(false);
             }
         }
         userViewModel.DOB = new DateTime(userViewModel.Year, userViewModel.Month, userViewModel.Day);
         User_UserDetails users = new User_UserDetails();
         users.UserId        = userViewModel.UserID;
         users.TitleID       = (int)userViewModel.TitleID;
         users.FirstName     = userViewModel.FirstName;
         users.LastName      = userViewModel.LastName;
         users.UserName      = userViewModel.Username;
         users.Telephone     = userViewModel.Telephone;
         users.Mobile        = userViewModel.Mobile;
         users.DateofBirth   = userViewModel.DOB;
         users.EmployeeNo    = userViewModel.EmployeeNO;
         users.JoinDate      = userViewModel.JoinDate;
         users.Email         = userViewModel.Email;
         users.Status        = userViewModel.Status;
         users.StatusComment = userViewModel.StatusComment;
         users.AddressID     = userViewModel.AddressID;
         users.JobTitleID    = (short)userViewModel.JobTitleID;
         db.User_UserDetails.Add(users);
         db.SaveChanges();
         msg = "Successfully Created!";
     }
     catch (Exception ex)
     {
         msg = ex.Message;
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
        /// <summary>
        /// update Company Information
        /// </summary>
        /// <param name="companyUpdateInfo"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public bool  UpdateCompanyInfo(CompanyInfoViewModel companyUpdateInfo, out string errorMsg, HttpPostedFileBase UploadFile)
        {
            errorMsg = "";


            if (companyUpdateInfo.Address.CountryID != 1)
            {
                errorMsg = "PAF Is Only Used For UK, So please Select a Country As a UK..!! ";
                return(false);
            }

            try
            {
                var companyDB = db.Common_HostSettings.ToList();

                companyDB.Where(x => x.HostKey.Equals("CompanyName")).Single().HostValue    = companyUpdateInfo.CompanyName;
                companyDB.Where(x => x.HostKey.Equals("EmailAddress")).Single().HostValue   = companyUpdateInfo.EmailAddress;
                companyDB.Where(x => x.HostKey.Equals("FaxNo")).Single().HostValue          = companyUpdateInfo.FaxNo;
                companyDB.Where(x => x.HostKey.Equals("RegistrationNo")).Single().HostValue = companyUpdateInfo.RegistrationNo;
                companyDB.Where(x => x.HostKey.Equals("TelephoneNo")).Single().HostValue    = companyUpdateInfo.TelephoneNo.ToString();
                companyDB.Where(x => x.HostKey.Equals("VATNo")).Single().HostValue          = companyUpdateInfo.VATNo;
                companyDB.Where(x => x.HostKey.Equals("Website")).Single().HostValue        = companyUpdateInfo.Website;
                companyDB.Where(x => x.HostKey.Equals("DateFormat")).Single().HostValue     = CommonDate().Where(x => x.DateFormatID.Equals(companyUpdateInfo.DateFormatID)).Select(x => x.DateFormat).Single();
                companyDB.Where(x => x.HostKey.Equals("Currency")).Single().HostValue       = CommonCurrency().Where(x => x.CurrencyID.Equals(companyUpdateInfo.CurrencyID)).Select(x => x.Currency).Single();
                companyDB.Where(x => x.HostKey.Equals("TimeZone")).Single().HostValue       = GetTimeZone().Where(x => x.Id.Equals(companyUpdateInfo.TimeZoneID)).Select(x => x.DisplayName).Single();
                companyDB.Where(x => x.HostKey.Equals("TimeFormat")).Single().HostValue     = CommonTime().Where(x => x.TimeID.Equals(companyUpdateInfo.TimeID)).Select(x => x.TimeFormat).Single();
                if (companyUpdateInfo.Address.Postcode != null)
                {
                    companyUpdateInfo.Address.AddressID = addressBL.CheckAddress(companyUpdateInfo.Address);
                    companyUpdateInfo.AddressID         = companyUpdateInfo.Address.AddressID;
                    if (companyUpdateInfo.Address.AddressID == 0)
                    {
                        errorMsg = "Company Details is Not Updated.......!";
                        return(false);
                    }
                    companyDB.Where(x => x.HostKey.Equals("AddressID")).Single().HostValue = companyUpdateInfo.Address.AddressID.ToString();
                }


                if (UploadFile != null)
                {
                    if (UploadFile.ContentType == "image/jpeg" || UploadFile.ContentType == "image/png" || UploadFile.ContentType == "image/gif")
                    {
                        Common_HostLogo ComLogo = db.Common_HostLogo.SingleOrDefault(x => x.LogoID == 8);
                        ComLogo.HostLogoContentType = UploadFile.ContentType;
                        ComLogo.HostLogoContent     = ConvertToBytes(UploadFile);

                        db.SaveChanges();
                        errorMsg = "Successfully Saved.......!";
                    }
                    else
                    {
                        errorMsg = "ImageType Should Be 'jpeg' Or 'png' Or 'gif' ";
                        return(false);
                    }
                }
                else
                {
                    Common_HostLogo CmHostlogo = new Common_HostLogo();
                    CmHostlogo.HostLogoContentType = null;
                    CmHostlogo.HostLogoContent     = null;

                    db.SaveChanges();
                    errorMsg = "SuccessFully Saved.......!";
                }
                return(true);
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
                return(false);
            }
        }