예제 #1
0
        public ActionResult Index([Bind(Include = "ProductsCapabilityId,CompanyId,Name,Description,CreatedBy,CreatedDate,ModifiedBy,ModifiedDate")] ProductsCapability productsCapability)
        {
            ViewBag.productsCapabilities = db.ProductsCapabilities.Where(a => a.CompanyId == productsCapability.CompanyId).ToList();
            ViewBag.CompanyId            = productsCapability.CompanyId;
            if (ModelState.IsValid)
            {
                if (productsCapability.ProductsCapabilityId == 0)
                {
                    productsCapability.CreatedDate  = DateTime.Now;
                    productsCapability.ModifiedDate = DateTime.Now;
                    db.ProductsCapabilities.Add(productsCapability);
                }
                else
                {
                    var record = db.ProductsCapabilities.FirstOrDefault(a => a.ProductsCapabilityId == productsCapability.ProductsCapabilityId);
                    record.Name            = productsCapability.Name;
                    record.CompanyId       = productsCapability.CompanyId;
                    record.ModifiedDate    = DateTime.Now;
                    db.Entry(record).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(RedirectToAction("Index", new { companyId = productsCapability.CompanyId }));
            }

            return(View(productsCapability));
        }
예제 #2
0
        public ActionResult ProformaProgramsPartial(ProformaProgramModel model)
        {
            var record = new ProformaProgram();

            if (model.ProformaProgramId > 0)
            {
                record = _db.ProformaPrograms.FirstOrDefault(a => a.ProformaProgramId == model.ProformaProgramId);
            }

            record.Name      = model.Name;
            record.CompanyId = model.CompanyId;


            if (model.ProformaProgramId == 0)
            {
                record.CreatedDate = DateTime.Now;
                _db.ProformaPrograms.Add(record);
            }
            else
            {
                record.ModifiedDate     = DateTime.Now;
                _db.Entry(record).State = EntityState.Modified;
            }
            _db.SaveChanges();

            ProformaProgramModel _ProformaProgramModel = GetProFormaPrograms(model.CompanyId);

            return(PartialView(_ProformaProgramModel));
        }
        public HttpResponseMessage SaveFeedback()
        {
            string UserId       = HttpContext.Current.Request.Form["UserId"];
            string FeedbackText = HttpContext.Current.Request.Form["FeedbackText"];
            // string CreatedDate = HttpContext.Current.Request.Form["CreatedDate"];
            string Rating = HttpContext.Current.Request.Form["Rating"];
            // string Status = HttpContext.Current.Request.Form["Status"];

            FeedbackResponse _FeedbackResponse = new FeedbackResponse();

            _FeedbackResponse.Flag    = "false";
            _FeedbackResponse.MESSAGE = "Insuficient Data";

            if (!string.IsNullOrEmpty(UserId) && !string.IsNullOrEmpty(FeedbackText))
            {
                Feedback _Feedback = new Feedback();
                _Feedback.FeedBackText = FeedbackText;
                _Feedback.Rating       = Convert.ToDouble(Rating);
                // _Feedback.Status = Status;
                // _Feedback.CreatedDateTime = Convert.ToDateTime(CreatedDate);
                _Feedback.CreatedBy = Convert.ToInt32(UserId);
                _db.Feedbacks.Add(_Feedback);
                _db.SaveChanges();
                _FeedbackResponse.Flag    = "true";
                _FeedbackResponse.MESSAGE = "Feedback saved successfully";
            }


            return(Request.CreateResponse(HttpStatusCode.OK, _FeedbackResponse));
        }
        // [ActionName("DeleteUserNotification")]
        public HttpResponseMessage DeleteUserNotification(long UserId, long NotificationId)
        {
            DeleteNotificationModel _DeleteNotification = new DeleteNotificationModel();

            _DeleteNotification.MESSAGE = "Delete User Notification";
            _DeleteNotification.Flag    = "false";
            var _NotificationToDelete = _db.UserNotifications.FirstOrDefault(a => a.UserId == UserId && a.NotificationId == NotificationId);

            if (null != _NotificationToDelete)
            {
                _DeleteNotification.Flag               = "true";
                _DeleteNotification.NotificationId     = NotificationId;
                _NotificationToDelete.Status           = Status.Deleted.ToString();
                _NotificationToDelete.ModifiedBy       = UserId;
                _NotificationToDelete.ModifiedDate     = DateTime.Now;
                _db.Entry(_NotificationToDelete).State = EntityState.Modified;
                _db.SaveChanges();
                _DeleteNotification.DeleteStatus = "Notification deleted successfully";
            }
            else
            {
                _DeleteNotification.DeleteStatus = "Notification was not found";
            }

            return(Request.CreateResponse(HttpStatusCode.OK, _DeleteNotification));
        }
        public ActionResult SetCompanyCategories()
        {
            var companies = _db.Companies.ToList();

            foreach (var comp in companies)
            {
                if (comp.CategoryId1 != null && comp.CategoryId1 > 0)
                {
                    CompanyCategory cCategory = new CompanyCategory();
                    cCategory.CompanyId  = comp.CompanyId;
                    cCategory.CategoryId = Convert.ToInt32(comp.CategoryId1);

                    _db.CompanyCategories.Add(cCategory);
                }
            }
            _db.SaveChanges();
            return(View());
        }
예제 #6
0
        // [ActionName("RegisterUser")]
        //public HttpResponseMessage RegisterUser(string EmailAddress, string Password)
        public HttpResponseMessage RegisterUser()
        {
            string EmailAddress = HttpContext.Current.Request.Form["EmailAddress"];
            string Password     = HttpContext.Current.Request.Form["Password"];
            string DeviceType   = HttpContext.Current.Request.Form["DeviceType"];
            string DeviceToken  = HttpContext.Current.Request.Form["DeviceToken"];
            var    response     = new RegisterResponse();

            response.Flag   = "false";
            response.UserId = 0;

            if (!string.IsNullOrEmpty(EmailAddress) && !string.IsNullOrEmpty(Password))
            {
                MembershipCreateStatus createStatus;
                MembershipUser         newUser = Membership.CreateUser(EmailAddress, Password, EmailAddress, "question", "answer", true, out createStatus);

                if (null != newUser)
                {
                    ProformaUsers obj = new ProformaUsers();
                    obj.AspUserId = new Guid(newUser.ProviderUserKey.ToString());

                    obj.DeviceToken = DeviceToken;
                    obj.DeviceType  = DeviceType;
                    obj.CreatedDate = DateTime.Now;
                    _db.ProformaUsers.Add(obj);
                    _db.SaveChanges();
                    response.Flag   = "true";
                    response.UserId = Convert.ToInt32(obj.UserID);
                }
                //else
                //{
                //    response.MESSAGE = "Failed to register";
                //}
                response.MESSAGE = createStatus.ToString();
            }
            else
            {
                response.MESSAGE = "Failed to register";
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public ActionResult UpdateCompanyInfo()
        {
            var _Companies = _db.Companies.ToList();

            if (_Companies != null || _Companies.Count() > 0)
            {
                foreach (var com in _Companies)
                {
                    var    _Company = _db.Companies.FirstOrDefault(a => a.CompanyId == com.CompanyId);
                    string address  = com.StreetAddress.Trim() + "+" + com.City.Trim() + "+" + com.ZipCode.Trim() + "+" + com.State.Trim();
                    var    latlng   = GetLatitudeLongitute(address);
                    if (!string.IsNullOrEmpty(latlng))
                    {
                        var arrlatlng = latlng.Split(new[] { '_' }).ToList();
                        _Company.Latitude  = Convert.ToDecimal(arrlatlng[0]);
                        _Company.Longitude = Convert.ToDecimal(arrlatlng[1]);
                    }
                    _db.Entry(_Company).State = EntityState.Modified;
                    _db.SaveChanges();
                }
            }
            return(View());
        }
예제 #8
0
        public JsonResult SavePLPCompanyInfo(string PLPCompanyInfoData)
        {
            string finalString = string.Empty;
            string original    = PLPCompanyInfoData;

            if (!string.IsNullOrEmpty(PLPCompanyInfoData))
            {
                PLPCompanyInfoData = PLPCompanyInfoData.Replace('"', '\'');

                var arr11 = PLPCompanyInfoData.Split(new string[] { "'lstAllCategories':" }, StringSplitOptions.None);
                var arr12 = arr11[1].Split(new string[] { ",'PrimaryContactFirstName'" }, StringSplitOptions.None);
                var cat1  = arr12[0];

                if (!cat1.Contains("["))
                {
                    var arrNumberOnly = cat1.Split(new string[] { "'" }, StringSplitOptions.RemoveEmptyEntries);
                    finalString = arr11[0] + "'lstAllCategories':" + "[" + arrNumberOnly[0] + "]" + ",'PrimaryContactFirstName'" + arr12[1];
                }
                else
                {
                    finalString = original;
                }
            }
            var serializer = new JavaScriptSerializer();

            var companyInfo           = serializer.Deserialize(finalString, typeof(PLPCompanyInfoModel));
            PLPCompanyInfoModel model = (dynamic)(companyInfo);

            if (model.CompanyId > 0)
            {
                var company = _db.Companies.FirstOrDefault(a => a.CompanyId == model.CompanyId);

                company.CompanyName                  = model.CompanyName;
                company.ASI                          = "" + model.ASI;
                company.PPAI                         = "" + model.PPAI;
                company.SAGE                         = "" + model.SAGE;
                company.StreetAddress                = "" + model.StreetAddress;
                company.City                         = "" + model.City;
                company.State                        = "" + model.State;
                company.ZipCode                      = "" + model.ZipCode;
                company.Website                      = "" + model.Website;
                company.FOBPointInCanada             = "" + model.FOBPointInCanada;
                company.PrimaryContactFirstName      = "" + model.PrimaryContactFirstName;
                company.PrimaryContactLastName       = "" + model.PrimaryContactLastName;
                company.PrimaryContactEmail          = "" + model.PrimaryContactEmail;
                company.PrimaryContactDirectLine     = "" + model.PrimaryContactDirectLine;
                company.PrimaryContactFax            = "" + model.PrimaryContactFax;
                company.PrimaryContactTradeOnly      = "" + model.PrimaryContactTradeOnly;
                company.PrimaryContactAffiliations   = "" + model.PrimaryContactAffilations;
                company.SecondaryContactFirstName    = "" + model.SecondaryContactFirstName;
                company.SecondaryContactLastName     = "" + model.SecondaryContactLastName;
                company.SecondaryContactEmail        = "" + model.SecondaryContactEmail;
                company.SecondaryContactDirectLine   = "" + model.SecondaryContactDirectLine;
                company.SecondaryContactFax          = "" + model.SecondaryContactFax;
                company.SecondaryContactTradeOnly    = "" + model.SecondaryContactTradeOnly;
                company.SecondaryContactAffiliations = "" + model.SecondaryContactAffilations;
                company.TertiaryContactFirstName     = "" + model.TertiaryContactFirstName;
                company.TertiaryContactLastName      = "" + model.TertiaryContactLastName;
                company.TertiaryContactEmail         = "" + model.TertiaryContactEmail;
                company.TertiaryContactDirectLine    = "" + model.TertiaryContactDirectLine;
                company.TertiaryContactFax           = "" + model.TertiaryContactFax;
                company.TertiaryContactTradeOnly     = "" + model.TertiaryContactTradeOnly;
                company.TertiaryContactAffiliations  = "" + model.TertiaryContactAffilations;
                company.Description                  = "" + model.Description;

                if (null != model.lstAllCategories && model.lstAllCategories.Count() > 0)
                {
                    var companyCategories = _db.CompanyCategories.Where(cc => cc.CompanyId == company.CompanyId).ToList();
                    foreach (var comp in companyCategories)
                    {
                        _db.CompanyCategories.Remove(comp);
                    }
                    _db.SaveChanges();

                    foreach (var id in model.lstAllCategories)
                    {
                        CompanyCategory _CompanyCategory = new CompanyCategory();
                        _CompanyCategory.CompanyId  = company.CompanyId;
                        _CompanyCategory.CategoryId = Convert.ToInt32(id);
                        _db.CompanyCategories.Add(_CompanyCategory);
                        _db.SaveChanges();
                    }
                }
                if (null == model.PartnerType)
                {
                    company.PartnerType = "PLP";
                }
                else
                {
                    company.PartnerType = "MVPLP";
                }
                if (!string.IsNullOrEmpty(model.CompanyLogo))
                {
                    company.Company_Logo = Path.Combine(Server.MapPath("~/Uploads/"), model.CompanyLogo);
                }
                else
                {
                    company.Company_Logo = "";
                }


                //_db.Entry(company).State = EntityState.Modified;
                //_db.SaveChanges();
            }

            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
        public ActionResult CompanyProgramsNProducts()
        {
            string[] stringSeparators = new string[] { ",", ". ", "\n", ";" };

            SourcingGuideDevEntities _db = new SourcingGuideDevEntities();
            var companies = _db.Companies.ToList();

            foreach (var comp in companies)
            {
                //Manage Proforma Programs
                var proformaProgram = comp.ProformaPrograms;

                if (!string.IsNullOrEmpty(proformaProgram))
                {
                    var lstProformaPrograms = proformaProgram.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); // proformaProgram.Split(new[] { ",", ". ", "\n", ";" }).ToList();
                    foreach (var pp in lstProformaPrograms)
                    {
                        var strProformaProgram = pp.Trim();
                        if (!string.IsNullOrEmpty(strProformaProgram))
                        {
                            var _ProformaProgram = _db.ProformaPrograms.FirstOrDefault(p => p.CompanyId == comp.CompanyId && p.Name == strProformaProgram);
                            if (null == _ProformaProgram)
                            {
                                _ProformaProgram             = new ProformaProgram();
                                _ProformaProgram.CompanyId   = comp.CompanyId;
                                _ProformaProgram.Name        = strProformaProgram;
                                _ProformaProgram.CreatedDate = DateTime.Now;
                                _db.ProformaPrograms.Add(_ProformaProgram);
                            }
                            else
                            {
                                _ProformaProgram.Name             = strProformaProgram;
                                _ProformaProgram.ModifiedDate     = DateTime.Now;
                                _db.Entry(_ProformaProgram).State = EntityState.Modified;
                            }
                        }
                    }
                }

                //Manage ProductsCapabilities
                var productsCapability = comp.ProductsNCapabilities;
                if (!string.IsNullOrEmpty(productsCapability))
                {
                    var lstProductsCapabilities = productsCapability.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); //productsCapability.Split(new[] { ',', '. ', '\n', ';' }).ToList();
                    foreach (var pc in lstProductsCapabilities)
                    {
                        var strProductsCapability = pc.Trim();
                        if (!string.IsNullOrEmpty(strProductsCapability))
                        {
                            var _ProductsCapability = _db.ProductsCapabilities.FirstOrDefault(p => p.CompanyId == comp.CompanyId && p.Name == strProductsCapability);
                            if (null == _ProductsCapability)
                            {
                                _ProductsCapability             = new ProductsCapability();
                                _ProductsCapability.CompanyId   = comp.CompanyId;
                                _ProductsCapability.Name        = strProductsCapability;
                                _ProductsCapability.CreatedDate = DateTime.Now;
                                _db.ProductsCapabilities.Add(_ProductsCapability);
                            }
                            else
                            {
                                _ProductsCapability.Name             = strProductsCapability;
                                _ProductsCapability.ModifiedDate     = DateTime.Now;
                                _db.Entry(_ProductsCapability).State = EntityState.Modified;
                            }
                        }
                    }
                }

                _db.SaveChanges();
            }

            ViewBag.OperationStatus = "ProformaPrograms/ProductsCapabilities updated successfully!";
            return(View());
        }
        public ActionResult ImportExcel()
        {
            SourcingGuideDevEntities _db = new SourcingGuideDevEntities();

            //string filePath = Server.MapPath("/Docs/2016MASTERSourceGuideListings.xlsx");
            string filePath  = "E:/Gotcha/Docs/2016MASTERSourceGuideListings.xlsx";
            var    excelFile = new FileInfo(filePath);

            List <Company> CompanyList = new List <Company>();
            const int      startRow    = 1;

            try
            {
                using (var package = new ExcelPackage(excelFile))
                {
                    // Get the work book in the file
                    ExcelWorkbook workBook = package.Workbook;
                    if (workBook != null)
                    {
                        if (workBook.Worksheets.Count > 0)
                        {
                            // Get the worksheet
                            foreach (ExcelWorksheet currentWorksheet in workBook.Worksheets)
                            {
                                for (int rowNumber = startRow + 1; rowNumber <= currentWorksheet.Dimension.End.Row; rowNumber++)
                                // read each row from the start of the data (start row + 1 header row) to the end of the spreadsheet.
                                {
                                    var categoryText = currentWorksheet.Name;

                                    string category = Convert.ToString(currentWorksheet.Cells[rowNumber, 1].Value).Trim();
                                    if (!string.IsNullOrEmpty(category))
                                    {
                                        int?categoryId = null;
                                        var cat        = _db.Categories.FirstOrDefault(c => c.Category1.ToLower() == categoryText.ToLower());
                                        if (null != cat)
                                        {
                                            categoryId = cat.CategoryId;
                                        }

                                        string MVPLP_PLP      = Convert.ToString(currentWorksheet.Cells[rowNumber, 2].Value);
                                        string Company_Name   = Convert.ToString(currentWorksheet.Cells[rowNumber, 3].Value);
                                        string Street_Address = Convert.ToString(currentWorksheet.Cells[rowNumber, 4].Value);
                                        string City           = Convert.ToString(currentWorksheet.Cells[rowNumber, 5].Value);
                                        string State          = Convert.ToString(currentWorksheet.Cells[rowNumber, 6].Value);
                                        string ZipCode        = Convert.ToString(currentWorksheet.Cells[rowNumber, 7].Value);
                                        string Phone_1        = Convert.ToString(currentWorksheet.Cells[rowNumber, 8].Value);
                                        string Phone_2        = Convert.ToString(currentWorksheet.Cells[rowNumber, 9].Value);
                                        string Fax            = Convert.ToString(currentWorksheet.Cells[rowNumber, 10].Value);
                                        string Website        = Convert.ToString(currentWorksheet.Cells[rowNumber, 11].Value);
                                        string FTPSite        = Convert.ToString(currentWorksheet.Cells[rowNumber, 12].Value);
                                        string ArtMail        = Convert.ToString(currentWorksheet.Cells[rowNumber, 13].Value);

                                        string OrderEmail                  = Convert.ToString(currentWorksheet.Cells[rowNumber, 14].Value);
                                        string FOB_pointinCanada           = Convert.ToString(currentWorksheet.Cells[rowNumber, 15].Value);
                                        string CanadianDollers             = Convert.ToString(currentWorksheet.Cells[rowNumber, 16].Value);
                                        string PrimaryContact_Name         = Convert.ToString(currentWorksheet.Cells[rowNumber, 17].Value);
                                        string PrimaryContact_Email        = Convert.ToString(currentWorksheet.Cells[rowNumber, 18].Value);
                                        string PrimaryContact_Extension    = Convert.ToString(currentWorksheet.Cells[rowNumber, 19].Value);
                                        string PrimaryContact_DirectLine   = Convert.ToString(currentWorksheet.Cells[rowNumber, 20].Value);
                                        string SecondaryContact_Name       = Convert.ToString(currentWorksheet.Cells[rowNumber, 21].Value);
                                        string SecondaryContact_Email      = Convert.ToString(currentWorksheet.Cells[rowNumber, 22].Value);
                                        string SecondaryContact_Extension  = Convert.ToString(currentWorksheet.Cells[rowNumber, 23].Value);
                                        string SecondaryContact_DirectLine = Convert.ToString(currentWorksheet.Cells[rowNumber, 24].Value);
                                        string TradeOnly = Convert.ToString(currentWorksheet.Cells[rowNumber, 25].Value);
                                        string Union     = Convert.ToString(currentWorksheet.Cells[rowNumber, 26].Value);

                                        string ASI                = Convert.ToString(currentWorksheet.Cells[rowNumber, 27].Value);
                                        string PPAI               = Convert.ToString(currentWorksheet.Cells[rowNumber, 28].Value);
                                        string PPPC               = Convert.ToString(currentWorksheet.Cells[rowNumber, 29].Value);
                                        string SAGE               = Convert.ToString(currentWorksheet.Cells[rowNumber, 30].Value);
                                        string UPIC               = Convert.ToString(currentWorksheet.Cells[rowNumber, 31].Value);
                                        string Certification      = Convert.ToString(currentWorksheet.Cells[rowNumber, 32].Value);
                                        string Minority_Owned     = Convert.ToString(currentWorksheet.Cells[rowNumber, 33].Value);
                                        string Proforma_Pricing   = Convert.ToString(currentWorksheet.Cells[rowNumber, 34].Value);
                                        string Proforma_Programs  = Convert.ToString(currentWorksheet.Cells[rowNumber, 35].Value);
                                        string Product_capability = Convert.ToString(currentWorksheet.Cells[rowNumber, 36].Value);
                                        string Rushor24hours      = Convert.ToString(currentWorksheet.Cells[rowNumber, 37].Value);

                                        Company _objCompany = new Company {
                                            CategoryId1 = categoryId, PartnerType = MVPLP_PLP, CompanyName = Company_Name, StreetAddress = Street_Address, City = City, State = State, ZipCode = ZipCode, Phone1 = Phone_1, Phone2 = Phone_2, PrimaryContactFax = Fax, Website = Website, FTPSite = FTPSite, ArtEmail = ArtMail, OrderEmail = OrderEmail, FOBPointInCanada = FOB_pointinCanada, QuoteinCanadianDollars = CanadianDollers, PrimaryContactFirstName = PrimaryContact_Name, PrimaryContactEmail = PrimaryContact_Email, PrimaryContactExtension = PrimaryContact_Extension, PrimaryContactDirectLine = PrimaryContact_DirectLine, SecondaryContactFirstName = SecondaryContact_Name, SecondaryContactEmail = SecondaryContact_Email, SecondaryContactExtension = SecondaryContact_Extension, SecondaryContactDirectLine = SecondaryContact_DirectLine, PrimaryContactTradeOnly = TradeOnly, Union = Union, ASI = ASI, PPAI = PPAI, PPPC = PPPC, SAGE = SAGE, UPIC = UPIC, Certifications = Certification, MinorityOwned = Minority_Owned, ProformaPricing = Proforma_Pricing, ProformaPrograms = Proforma_Programs, ProductsNCapabilities = Product_capability, Rushor24hour = Rushor24hours
                                        };

                                        _db.Companies.Add(_objCompany);
                                    }
                                }
                            }
                        }
                    }
                }

                _db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            }

            return(View());
        }