Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Name,Message,AttachmentFile,Email")] ContactViewModel ContactViewModel1)
        {
            if (ModelState.IsValid)
            {
                Contact Contact1 = new Contact();
                Contact1.Name    = ContactViewModel1.Name;
                Contact1.Message = ContactViewModel1.Message;
                Contact1.Email   = ContactViewModel1.Email;

                PersianDateTime PersianDateTime1 = new PersianDateTime();
                Contact1.MessageDateTime = PersianDateTime1.GregorianToShamsi(DateTime.Now);

                if (ContactViewModel1.AttachmentFile != null)
                {
                    Contact1.AttachmentFileName = ContactViewModel1.AttachmentFile.FileName;
                    byte[] uploadFile = new byte[ContactViewModel1.AttachmentFile.InputStream.Length];
                    ContactViewModel1.AttachmentFile.InputStream.Read(uploadFile, 0, uploadFile.Length);
                    Contact1.AttachmentFile = uploadFile;
                    //byte[] uploadFile = new byte[file1.InputStream.Length];
                    //file1.InputStream.Read(uploadFile, 0, uploadFile.Length);
                    //Contact1.AttachmentFile = uploadFile;
                }

                db.Contacts.Add(Contact1);
                db.SaveChanges();
                return(RedirectToAction("Thanks"));
            }

            return(View(ContactViewModel1));
        }
        public ActionResult Create([Bind(Include = "RequestByName,MainSite,SiteSecondary,RequestType,Description")] RequestUserViewModel requestUserViewModel)
        {
            if (ModelState.IsValid)
            {
                PersianDateTime persianDateTime = new PersianDateTime();
                requestUserViewModel.RequestDate = persianDateTime.GregorianToShamsi(DateTime.Now);
                RepairRequest repairRequest = requestUserViewModel.MapViewModelToModel();
                repairRequest.PlanningTodo = true;
                _repairRequestService.Add(repairRequest);
                _uow.SaveChanges();
                return(RedirectToAction("Index"));
            }

            var mainSiteList = new SelectList(new[] { "سایت 1 - مرکزی",
                                                      "سایت 2 - اداری 2",
                                                      "سایت 3 - بازارچه",
                                                      "سایت 4 - کمپ 4",
                                                      "سایت 5 - پایانه بار",
                                                      "سایت 6 - اسکله و بندر",
                                                      "سایت 7 - شیرینو",
                                                      "سایت 8 - کمپ EPC", });

            ViewBag.MainSiteList = mainSiteList;

            var requestType = new SelectList(new[] { "تعميرات", "نصب تجهيزات جديد" });

            ViewBag.RequestType = requestType;

            return(View(requestUserViewModel));
        }
Exemplo n.º 3
0
        /// <summary>
        /// کمترین قیمت گلد در حال حاضر برگردانده میشود
        /// </summary>
        /// <returns></returns>
        public GoldPriceViewModel Get()
        {
            GoldPriceViewModel GoldPriceViewModel1 = new GoldPriceViewModel();

            PersianDateTime PersianDateTime1 = new PersianDateTime();

            //دریافت قیمت فعلی کلد
            GoldPriceViewModel1.LowestPrice = 1;
            GoldPriceViewModel1.DateTime    = PersianDateTime1.GregorianToShamsi(DateTime.UtcNow);
            return(GoldPriceViewModel1);
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Message")] Log log)
        {
            if (ModelState.IsValid)
            {
                PersianDateTime PersianDateTime = new PersianDateTime();
                log.DateTime = PersianDateTime.GregorianToShamsi(DateTime.UtcNow);
                db.Logs.Add(log);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(log));
        }