示例#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
        //[ActionName("Login")]
        //public HttpResponseMessage Login(string UserName,string Password)
        public HttpResponseMessage Login()
        {
            string UserName    = HttpContext.Current.Request.Form["UserName"];
            string Password    = HttpContext.Current.Request.Form["Password"];
            string DeviceType  = HttpContext.Current.Request.Form["DeviceType"];
            string DeviceToken = HttpContext.Current.Request.Form["DeviceToken"];
            var    response    = new LoginResponse();

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

            if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
            {
                if (Membership.ValidateUser(UserName, Password))
                {
                    MembershipUser currentUser   = Membership.GetUser(UserName);
                    Guid           currentUserId = new Guid(currentUser.ProviderUserKey.ToString());

                    var userrecord = _db.ProformaUsers.FirstOrDefault(a => a.AspUserId == currentUserId);
                    if (null != userrecord)
                    {
                        //bool IsPasswordValid = BCrypt.Net.BCrypt.Verify(Password, userrecord.Password);
                        // if (IsPasswordValid)
                        // {
                        userrecord.IsActive    = true;
                        userrecord.DeviceType  = DeviceType;
                        userrecord.DeviceToken = DeviceToken;

                        _db.Entry(userrecord).State = System.Data.Entity.EntityState.Modified;
                        _db.SaveChanges();
                        response.Flag    = "true";
                        response.MESSAGE = "Login successful";
                        response.UserId  = Convert.ToInt32(userrecord.UserID);
                        //}
                        // else
                        // {
                        //    response.MESSAGE = "Invalid Password";
                        // }
                    }

                    else
                    {
                        response.MESSAGE = "Invalid Email Address";
                    }
                }
                else
                {
                    response.MESSAGE = "Login fail";
                }
            }
            else
            {
                response.MESSAGE = "Login fail";
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
示例#3
0
        public JsonResult SaveEvent(string EventInfo)
        {
            var serializer            = new JavaScriptSerializer();
            var eventInfo             = serializer.Deserialize(EventInfo, typeof(ProformaEventsModel));
            ProformaEventsModel model = (dynamic)(eventInfo);
            Event _event = new Event();

            if (model.EventId > 0)
            {
                _event = _db.Events.FirstOrDefault(a => a.EventId == model.EventId);
                _event.ModifiedDate = DateTime.Now;
            }
            else
            {
                _event.CreatedDate     = DateTime.Now;
                _event.EventSubHeading = "";
            }

            _event.EventTitle      = model.EventTitle;
            _event.Description     = model.EventDescription;
            _event.EventSubHeading = model.ShortDescription;
            //_event.EventEndDate = model.EventEndDate;
            //_event.EventStartDate = model.EventStartDate;
            _event.Image  = "http://psgapp.proforma.com//Uploads/" + model.EventImage;
            _event.Status = "Active";
            if (model.EventId > 0)
            {
                _db.Entry(_event).State = EntityState.Modified;
            }
            else
            {
                _db.Events.Add(_event);
            }

            _db.SaveChanges();
            ProformaEventResponseModel response = new ProformaEventResponseModel();

            response.EventId        = _event.EventId;
            response.EventStartDate = _event.EventStartDate;
            response.EventEndDate   = _event.EventEndDate;
            response.Description    = _event.Description;
            response.EventTitle     = _event.EventTitle;
            response.EventImage     = _event.Image;

            response.Message = "Success";

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        // [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));
        }
示例#5
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 ActionResult RegisterExistingUsers()
        {
            // Attempt to register the user

            var lstUsers = _db.ProformaUsers.Where(u => u.AspUserId == null).ToList();

            foreach (var user in lstUsers)
            {
                MembershipCreateStatus createStatus;
                MembershipUser         newUser = Membership.CreateUser(user.Email, "Proforma2016!", "", "question", "answer", true, out createStatus);
                if (null != newUser)
                {
                    user.AspUserId        = new Guid(newUser.ProviderUserKey.ToString());
                    _db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                    _db.SaveChanges();
                }
            }

            return(View());
        }
        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());
        }
        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());
        }