Exemplo n.º 1
0
        public ActionResult WorkshopProfileEdit(WorkshopModel model)
        {
            var workshopSession = Session["LoginWorkshop"] as SessionModel;

            if (workshopSession != null)
            {
                using (var db = new MechAppProjectEntities())
                {
                    var workshopModel = db.Workshops.FirstOrDefault(x => x.WorkshopId == workshopSession.WorkshopId);

                    workshopModel.Password     = model.Password;
                    workshopModel.Email        = model.Email;
                    workshopModel.WorkshopName = model.WorkshopName;
                    workshopModel.OwerName     = model.OwnerName;
                    workshopModel.PhoneNbr     = model.PhoneNbr;
                    workshopModel.City         = model.City;
                    workshopModel.Street       = model.Street;
                    workshopModel.StreetNbr    = model.StreetNbr;
                    workshopModel.ZipCode      = model.ZipCode;

                    db.SaveChanges();
                }
            }

            return(RedirectToAction("WorkshopProfile"));
        }
Exemplo n.º 2
0
        public ActionResult AddWorkshopDescription(WorkshopDescriptionModel objWorkshopDescriptionModel)
        {
            var userSession = Session["LoginWorkshop"] as SessionModel;

            if (userSession != null)
            {
                using (var db = new MechAppProjectEntities())
                {
                    var WorkshopDecrtiptionModel = db.WorkshopDescriptions.Where(x => x.WorkshopDescriptionID == userSession.WorkshopId);
                    MechAppProjectEntities objMechAppProjectEntities = new MechAppProjectEntities();
                    WorkshopDescription    objWorkshopDescription    = new WorkshopDescription
                    {
                        WorkshopId  = userSession.WorkshopId,
                        WorkshopDes = objWorkshopDescriptionModel.WorkshopDes
                    };

                    db.WorkshopDescriptions.Add(objWorkshopDescription);
                    db.SaveChanges();

                    ModelState.Clear();
                    ViewBag.SuccessMessage = "Opis dodany";
                    return(RedirectToAction("Index", "Home"));
                }
            }

            return(View());
        }
Exemplo n.º 3
0
        public ActionResult WorkshopProfileEdit()
        {
            {
                var model           = new WorkshopModel();
                var workshopSession = Session["LoginWorkshop"] as SessionModel;
                if (workshopSession != null)
                {
                    using (var db = new MechAppProjectEntities())
                    {
                        var workshop = db.Workshops.FirstOrDefault(x => x.WorkshopId == workshopSession.WorkshopId);

                        model.Login        = workshop.Login;
                        model.Password     = workshop.Password;
                        model.Email        = workshop.Email;
                        model.WorkshopName = workshop.WorkshopName;
                        model.OwnerName    = workshop.OwerName;
                        model.City         = workshop.City;
                        model.Street       = workshop.Street;
                        model.StreetNbr    = workshop.StreetNbr;
                        model.ZipCode      = workshop.ZipCode;
                        model.PhoneNbr     = workshop.PhoneNbr;
                    }
                    return(View(model));
                }
                return(View());
            }
        }
Exemplo n.º 4
0
        public ActionResult WorkshopSitePanel(int workshopId)
        {
            var viewModel = new WorkshopSitePanelModel();

            using (var db = new MechAppProjectEntities())
            {
                var workshop         = db.Workshops.First(x => x.WorkshopId == workshopId);
                var workshopServices = db.WorkshopServices.Where(x => x.WorkshopId == workshopId).ToList();

                viewModel.ZipCode      = workshop.ZipCode;
                viewModel.WorkshopName = workshop.WorkshopName;
                viewModel.StreetNbr    = workshop.StreetNbr;
                viewModel.Street       = workshop.Street;
                viewModel.PhoneNbr     = workshop.PhoneNbr;
                viewModel.OwnerName    = workshop.OwerName;
                viewModel.Email        = workshop.Email;
                viewModel.City         = workshop.City;

                foreach (var workshopService in workshopServices)
                {
                    viewModel.WorkshopServices.Add(new WorkshopServiceModel()
                    {
                        Description       = workshopService.Description,
                        DurationInHours   = workshopService.DurationInHours,
                        DurationInMinutes = workshopService.DurationInMinutes,
                        Price             = workshopService.Price,
                        PriceDecimal      = workshopService.PriceDecimal,
                        Title             = workshopService.Title,
                        WorkshopId        = workshopService.WorkshopId
                    });
                }
            }

            return(View(viewModel));
        }
Exemplo n.º 5
0
        public ActionResult CustomerProfileEdit(CustomerModel model)
        {
            var userSession = Session["Login"] as SessionModel;

            if (userSession != null)
            {
                using (var db = new MechAppProjectEntities())
                {
                    var customerModel = db.Customers.FirstOrDefault(x => x.CustomerId == userSession.UserId);


                    customerModel.Password  = model.Password;
                    customerModel.Email     = model.Email;
                    customerModel.Name      = model.Name;
                    customerModel.Surname   = model.Surname;
                    customerModel.City      = model.City;
                    customerModel.Street    = model.Street;
                    customerModel.StreetNbr = model.StreetNbr;
                    customerModel.ZipCode   = model.ZipCode;
                    customerModel.PhoneNbr  = model.PhoneNbr;

                    db.SaveChanges();
                }
            }

            return(RedirectToAction("CustomerProfile"));
        }
Exemplo n.º 6
0
        public ActionResult CustomerProfileEdit()

        {
            var model       = new CustomerModel();
            var userSession = Session["Login"] as SessionModel;

            if (userSession != null)
            {
                using (var db = new MechAppProjectEntities())
                {
                    var customer = db.Customers.FirstOrDefault(x => x.CustomerId == userSession.UserId);

                    model.Login     = customer.Login;
                    model.Password  = customer.Password;
                    model.Email     = customer.Email;
                    model.Name      = customer.Name;
                    model.Surname   = customer.Surname;
                    model.City      = customer.City;
                    model.Street    = customer.Street;
                    model.StreetNbr = customer.StreetNbr;
                    model.ZipCode   = customer.ZipCode;
                    model.PhoneNbr  = customer.PhoneNbr;
                }
                return(View(model));
            }
            return(View());
        }
Exemplo n.º 7
0
        public ActionResult DeleteWorkshopService(int workshopServiceId)
        {
            using (var db = new MechAppProjectEntities())
            {
                var service = db.WorkshopServices.First(x => x.ServiceId == workshopServiceId);

                db.WorkshopServices.Remove(service);
                db.SaveChanges();
            }

            return(Json(new { success = true, workshopServiceId = workshopServiceId }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public ActionResult YourDescription()
        {
            var model       = new WorkshopDescriptionModel();
            var userSession = Session["LoginWorkshop"] as SessionModel;


            using (var db = new MechAppProjectEntities())
            {
                var workshopDescription = db.WorkshopDescriptions.FirstOrDefault(x => x.WorkshopId == userSession.WorkshopId);

                model.WorkshopDes = workshopDescription.WorkshopDes;
            }

            return(View(model));
        }
Exemplo n.º 9
0
        public ActionResult CustomerProfile()
        {
            var model       = new CustomerModel();
            var userSession = Session["Login"] as SessionModel;

            if (userSession != null)
            {
                using (var db = new MechAppProjectEntities())
                {
                    var customer = db.Customers.FirstOrDefault(x => x.CustomerId == userSession.UserId);

                    model.Login    = customer.Login;
                    model.Password = customer.Password;
                    model.Email    = customer.Email;
                    model.Name     = customer.Name;
                }
            }

            return(View(model));
        }
Exemplo n.º 10
0
        public ActionResult SendMessage(ChatModel model)
        {
            int currentChatId   = 0;
            var newChat         = new Chat();
            var userSession     = Session["Login"] as SessionModel;
            var workshopSession = Session["LoginWorkshop"] as SessionModel;

            if (userSession != null || workshopSession != null)
            {
                var sentBy = string.Empty;
                var sentTo = string.Empty;

                if (userSession != null)
                {
                    sentBy = model.CurrentCustomerEmail;
                    sentTo = model.CurrentWorkshopEmail;
                }

                if (workshopSession != null)
                {
                    sentBy = model.CurrentWorkshopEmail;
                    sentTo = model.CurrentCustomerEmail;
                }

                using (var db = new MechAppProjectEntities())
                {
                    if (model.CurrentChatId > 0)
                    {
                        var chat = db.Chats.FirstOrDefault(x => x.ChatId == model.CurrentChatId);

                        if (chat != null)
                        {
                            var newMessage = SerializeChatMessage(new ChatMessageModel()
                            {
                                Message = model.CurrentMessage, Date = DateTime.Now, SentBy = sentBy, SentTo = sentTo
                            });
                            chat.Message += newMessage;
                        }

                        currentChatId = chat.ChatId;
                    }
                    else
                    {
                        newChat = new Chat()
                        {
                            CustomerId = model.CurrentCustomerId,
                            WorkshopId = model.CurrentWorkshopId,
                            Message    = SerializeChatMessage(new ChatMessageModel()
                            {
                                Message = model.CurrentMessage, Date = DateTime.Now, SentBy = sentBy, SentTo = sentTo
                            })
                        };

                        db.Chats.Add(newChat);
                    }

                    db.SaveChanges();

                    if (model.CurrentChatId <= 0)
                    {
                        currentChatId = newChat.ChatId;
                    }
                }
            }

            return(RedirectToAction("Index", new { currentChat = currentChatId }));
        }
Exemplo n.º 11
0
        // GET: Chat
        public ActionResult Index(int?currentChat, int?workshopId)
        {
            var userSession     = Session["Login"] as SessionModel;
            var workshopSession = Session["LoginWorkshop"] as SessionModel;
            var model           = new ChatModel();

            if (userSession != null || workshopSession != null)
            {
                if (workshopId > 0)
                {
                    using (var db = new MechAppProjectEntities())
                    {
                        var workshop = db.Workshops.First(x => x.WorkshopId == workshopId);

                        model.TemporaryChat        = true;
                        model.CurrentWorkshopName  = workshop.WorkshopName;
                        model.Messages             = new List <ChatMessageModel>();
                        model.CurrentWorkshopId    = workshop.WorkshopId;
                        model.CurrentCustomerId    = userSession.UserId;
                        model.CurrentCustomerEmail = db.Customers.First(x => x.CustomerId == userSession.UserId).Email;
                        model.CurrentWorkshopEmail = workshop.Email;
                    }
                }

                if (currentChat > 0)
                {
                    using (var db = new MechAppProjectEntities())
                    {
                        var chat = db.Chats.First(x => x.ChatId == currentChat);

                        model.CurrentChatId        = currentChat.Value;
                        model.CurrentWorkshopName  = chat.Workshop.WorkshopName;
                        model.Messages             = DeserializeChatMessages(chat.Message);
                        model.CurrentWorkshopId    = chat.WorkshopId;
                        model.CurrentCustomerId    = chat.CustomerId;
                        model.CurrentCustomerEmail = chat.Customer.Email;
                        model.CurrentWorkshopEmail = chat.Workshop.Email;
                    }
                }

                using (var db = new MechAppProjectEntities())
                {
                    var chats = new List <Chat>();

                    if (userSession != null)
                    {
                        model.IsCustomer = true;
                        chats            = db.Chats.Where(x => x.CustomerId == userSession.UserId).ToList();
                    }

                    if (workshopSession != null)
                    {
                        chats = db.Chats.Where(x => x.WorkshopId == workshopSession.WorkshopId).ToList();
                    }

                    foreach (var chat in chats)
                    {
                        model.ChatRooms.Add(new ChatRoomModel()
                        {
                            ChatId       = chat.ChatId,
                            WorkshopName = chat.Workshop.WorkshopName,
                            CustomerName = chat.Customer.Name
                        });
                    }
                }
            }

            return(View(model));
        }
Exemplo n.º 12
0
        public ActionResult YourServices(string sortOrder, string currentFilter, string searchString, int?page)
        {
            var viewModel = new List <WorkshopServiceModel>();
            var session   = Session["LoginWorkshop"] as SessionModel;

            if (session != null)
            {
                using (var db = new MechAppProjectEntities())
                {
                    var services = db.WorkshopServices.Where(x => x.WorkshopId == session.WorkshopId).ToList();

                    foreach (var workshopService in services)
                    {
                        var workshopServiceModel = new WorkshopServiceModel()
                        {
                            ServiceId         = workshopService.ServiceId,
                            WorkshopId        = session.WorkshopId,
                            Title             = workshopService.Title,
                            Description       = workshopService.Description,
                            Price             = workshopService.Price,
                            PriceDecimal      = workshopService.PriceDecimal,
                            DurationInHours   = workshopService.DurationInHours,
                            DurationInMinutes = workshopService.DurationInMinutes,
                        };

                        viewModel.Add(workshopServiceModel);
                    }
                }
            }

            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var eventsView = from w in viewModel
                             select w;

            if (!String.IsNullOrEmpty(searchString))
            {
                eventsView = eventsView.Where(w => w.Title.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "name_desc":
                eventsView = eventsView.OrderByDescending(w => w.Title);
                break;

            default:      // Name ascending
                eventsView = eventsView.OrderBy(w => w.Title);
                break;
            }

            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            return(View(eventsView.ToPagedList(pageNumber, pageSize)));
        }