// // GET: /Home/ public async Task <ActionResult> Index() { ServicesModel model = new ServicesModel(); NewsClient newsClient = new NewsClient(); WeatherClient weatherClient = new WeatherClient(); model.AddMessage("Index запущен"); model.AddMessage("Выполнение задачи получения новостей"); // После вызова метода newsClient.GetNewsAsync() поток IIS вернется в пул потоков. // Поток, который был создан в методе GetNewsAsync() получив ответ от службы продолжит выполнение // данного метода действия. model.News = await newsClient.GetNewsAsync(); // задержка 2 секунды model.AddMessage("Выполнение задачи получения температуры"); // На этом этапе будет создан еще один поток, предыдущий поток прекратит свою работу. model.Weather = await weatherClient.GetWeatherInfoAsync(); // задержка 2 секунды model.AddMessage("Index завершен"); // ответ клиенту будет возвращать поток который был создан при вызове GetWeatherInfoAsync() return(View(model)); }
public ActionResult Edit(WorkModel workModel, int[] service, int customer, int item) { if (service != null) { foreach (var id in service) { ServicesModel ser = wl.db.Services.Find(id); workModel.service.Add(ser); } } if (customer != 0) { CustomersModel cm = wl.db.Customers.Find(customer); workModel.customer = cm; } if (item != 0) { ServiceItemsModel sim = wl.db.ServiceItems.Find(item); workModel.item = sim; } wl.edit(workModel); return(RedirectToAction("Index")); }
// Метод будет запущен когда значение счетчика OutstandingOperations будет равное 0 public ActionResult IndexCompleted(ServicesModel model) { model.AddMessage("IndexCompleted запущен"); ViewBag.Header = "MVC3 Async Controller"; return(View(model)); }
public ActionResult ManageServices(string id = "") { ServicesCommon servicesCommon = new ServicesCommon(); var productid = id.DecryptParameter(); if (!String.IsNullOrEmpty(productid)) { //return RedirectToAction("Index"); servicesCommon = _services.GetServicesByProductId(Int32.Parse(productid)); servicesCommon.ProductId = servicesCommon.ProductId.EncryptParameter(); } servicesCommon.StatusList = LoadDropdownList("status") as List <SelectListItem>; servicesCommon.CompanyList = ApplicationUtilities.SetDDLValue(LoadDropdownList("company") as Dictionary <string, string>, servicesCommon.Company, "Select Company"); servicesCommon.TransactionTypeList = ApplicationUtilities.SetDDLValue(LoadDropdownList("txntype") as Dictionary <string, string>, servicesCommon.TransactionType, "Select Transaction Type"); servicesCommon.ProductTypeList = ApplicationUtilities.SetDDLValue(LoadDropdownList("producttype") as Dictionary <string, string>, servicesCommon.ProductType, "Select Product Type"); servicesCommon.ProductCategoryList = ApplicationUtilities.SetDDLValue(LoadDropdownList("productcategory") as Dictionary <string, string>, servicesCommon.ProductCategory, "Select Product Category"); servicesCommon.PrimaryGatewayList = ApplicationUtilities.SetDDLValue(LoadDropdownList("primarygateway") as Dictionary <string, string>, servicesCommon.PrimaryGateway, "Select Primary Gateway"); servicesCommon.SecondaryGatewayList = ApplicationUtilities.SetDDLValue(LoadDropdownList("secondarygateway") as Dictionary <string, string>, servicesCommon.SecondaryGateway, "Select Secondary Gateway"); ServicesModel lst = servicesCommon.MapObject <ServicesModel>(); return(View(lst)); }
public ActionResult Edit(ServicesModel input) { if (ModelState.IsValid) { var entity = new tb_Contents(); entity.CategoryId = input.CategoryId; entity.Content = input.Content; entity.Date = input.Date; entity.Description = input.Description; entity.Id = input.Id; entity.Meta_Description = input.Meta_Description; entity.Meta_Keyword = input.Meta_Keyword; entity.Meta_Title = input.Meta_Title; entity.Modified = input.Modified; entity.Name = input.Name; entity.Order = input.Order; entity.ParentId = input.ParentId; entity.Slug = input.Slug; entity.Status = input.Status; entity.Taxonomy = input.Taxonomy; entity.Thumbnail = input.Thumbnail; entity.Title = input.Title; entity.UserId = input.UserId; entity.View = input.View; entity.Modified = Convert.ToDateTime(input.Modified); Dao.Update(entity); } ViewBag.CategoryId = new SelectList(DaoCategories.ListAllByTaxonomy("Service"), "Id", "Title", input.CategoryId); return(View(input)); }
async void OnItemSelected(ServicesModel item) { if (item == null) { return; } switch (item.Id) { case 0: break; case 1: await Shell.Current.GoToAsync($"{nameof(MilkOrderPage)}"); break; case 2: break; case 3: break; case 4: break; case 5: break; default: break; } }
public ActionResult Create(ServicesModel model) { CreateService(model.Name, model.Active); return(RedirectToAction("ViewServices")); }
public static int SaveAvailableService(ServicesModel ServicesModel, string Action) { //SqlParameter[] parameters = //{ // new SqlParameter("@ServicePlanID", SqlDbType.Int, 10, ParameterDirection.Input, false, 10, 0, "ServicePlanID", DataRowVersion.Proposed, vehicleservicehistorydetails.ServicePlanID), // new SqlParameter("@ServiceName", SqlDbType.NVarChar, 10, ParameterDirection.Input, false, 10, 0, "ServiceName", DataRowVersion.Proposed, vehicleservicehistorydetails.ServiceName), // new SqlParameter("@Description", SqlDbType.NVarChar, max, ParameterDirection.Input, false, 10, 0, "Description", DataRowVersion.Proposed, vehicleservicehistorydetails.ServiceDescription), // new SqlParameter("@Action", SqlDbType.NVarChar, 10, ParameterDirection.Input, false, 10, 0, "Action", DataRowVersion.Proposed, Action) //}; List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@ServicePlanID", ServicesModel.AvailableServiceID)); parameters.Add(new SqlParameter("@ServiceName", ServicesModel.ServiceName)); parameters.Add(new SqlParameter("@Description", ServicesModel.Description)); parameters.Add(new SqlParameter("@IsUserCheckApplicable", ServicesModel.IsUserCheckApplicable)); parameters.Add(new SqlParameter("@BusinessCondition", ServicesModel.BusinessCondition)); parameters.Add(new SqlParameter("@Action", Action)); try { string ConnectionString = Common.GetConnectionString(); int rowsAffected = SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "spSaveAvailableService", parameters.ToArray()); return(rowsAffected); } catch (Exception e) { //loggerErr.Error(e.Message + " - " + e.StackTrace); throw e; } }
// // GET: /Home/ // public async Task <ActionResult> Index() { ServicesModel model = new ServicesModel(); model.AddMessage("Запуск метода действия"); #region Вызов асинхронных задач. Не корректное поведение контроллера GetLastNewsAsync(model); GetWeatherAsync(model); #endregion #region 1. Последовательное выполнение с await //await GetLastNewsAsync(model); //await GetWeatherAsync(model); #endregion #region 2. Параллельное выполнение c await //Task newsTask = GetLastNewsAsync(model); //Task weatherTask = GetWeatherAsync(model); //await Task.WhenAll(newsTask, weatherTask); #endregion model.AddMessage("Завершение метода действия"); ViewBag.Header = "Асинхронный метод действия с параллельными задачами"; return(View(model)); }
public List <ServicesModel> GenerateServicesModel() { List <ServicesModel> modelList = new List <ServicesModel>(); ServicesModel model = new ServicesModel(); try { using (VenturadaDataContext vdc = new VenturadaDataContext()) { var tableList = from p in vdc.Services.ToList() orderby p.ServicesId ascending select p; foreach (var item in tableList) { model = new ServicesModel(); model.ServicesId = item.ServicesId; model.ServiceName = item.ServiceName; model.ServiceSubTitle = item.ServiceSubTitle; model.ServiceDescription = item.ServiceDescription; model.ImageString = item.ImageString; modelList.Add(model); } return(modelList); } } catch (Exception ex) { throw ex; } }
public ActionResult DeleteConfirmed(int id) { ServicesModel servicesModel = sl.find(id); sl.remove(servicesModel); return(RedirectToAction("Index")); }
// // GET: /Home/ // В данном контроллере метод IndexAsync будет выполнен потоком из пула потоков IIS // Во время выполнения метода IndexAsync будет запущено несколько асинхронных задач. // Когда все асинхронные задачи завершат работу в отдельном потоке // будет запущен метод IndexCompleted, который вернет ответ клиенту. // В данном случае поток из пула IIS будет блокирован минимальное время и сможет обработать большее // количество входящих запросов. public void IndexAsync() { ServicesModel model = new ServicesModel(); NewsClient newsClient = new NewsClient(); WeatherClient weatherClient = new WeatherClient(); AsyncManager.Parameters["model"] = model; model.AddMessage("IndexAsync запущен"); AsyncManager.OutstandingOperations.Increment(); // указываем, что появляется новая асинхронная задача. (счетчик +1) newsClient.BeginGetNews(ar => { model.AddMessage("Выполнение задачи получения новостей"); model.News = newsClient.EndGetNews(ar); AsyncManager.OutstandingOperations.Decrement(); // указываем, что асинхронная задача завершена. (счетчик -1) }); AsyncManager.OutstandingOperations.Increment(); // указываем, что появляется новая асинхронная задача. (счетчик +1) weatherClient.BeginGetTempereture(ar => { model.AddMessage("Выполнение задачи получения температуры"); model.Weather = weatherClient.EndGetWeatherInfo(ar); AsyncManager.OutstandingOperations.Decrement(); // указываем, что асинхронная задача завершена. (счетчик -1) }); }
public static void AddClient(ClientsModel model, ServicesModel ModelServices, int postedbyId) { DataContext db = new DataContext(); TblClient tbl = new TblClient(); TblBusinessType tblBusinessType = new TblBusinessType(); tbl.Name = model.Name; tbl.TypeOfCompany = model.TypeOfCompany; tbl.LimitedBy = model.LimitedBy; tbl.ShareValue1 = model.ShareValue1; tbl.ShareValue2 = model.ShareValue2; tbl.ShareCapitalProduct = model.ProductOfShareValues; tbl.BusinessObjectives = model.BusinessObjectives; tbl.CNIC = model.CNIC; tbl.NTN = model.NTN; tbl.PINCode = model.PINCode; tbl.FBRLogin = model.FBRLogin; tbl.FBRPassword = model.FBRPassword; tbl.IncorporationNo = model.IncorporationNo; tbl.RegistrationNo = model.RegistrationNo; tbl.RegisteredWith = model.RegisteredWith; tbl.Address = model.Address; tbl.Email = model.Email; tbl.PhoneNo = model.PhoneNo; tbl.MobileNo = model.MobileNo; tbl.FaxNo = model.FaxNo; tbl.CreatedById = postedbyId; tbl.CreatedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); tbl.IsActive = true; db.TblClients.InsertOnSubmit(tbl); db.SubmitChanges(); TblService tblServices = new TblService(); var res = (from c in db.TblClients orderby c.Id descending select c).FirstOrDefault(); tbl = res; int currentClientId = tbl.Id; tblServices.ClientId = currentClientId; tblBusinessType.BusinessType = model.BusinessType; tblBusinessType.ClientId = currentClientId; tblServices.Accounting = true ? ModelServices.Accounting == "Accounting" : false; tblServices.Audit = true ? ModelServices.Audit == "Audit" : false; tblServices.Legal = true ? ModelServices.Legal == "Legal" : false; tblServices.Taxation = true ? ModelServices.Taxation == "Taxation" : false; tblServices.Corporate = true ? ModelServices.Corporate == "Corporate" : false; db.TblBusinessTypes.InsertOnSubmit(tblBusinessType); db.TblServices.InsertOnSubmit(tblServices); db.SubmitChanges(); db.Dispose(); //UpdateAndSaveService( ModelServices, currentClientId); }
protected override void LoadData() { //Fetching user's Google drive document list. DocumentsFeed feed = ServicesModel.GetGDriveDocList(); //Checking for errors in Model class if (ServicesModel.Error != null) { //Displaying error to user MessageBox.Show(ServicesModel.Error.Message + ".\n Please recheck the access code you've entered.", "Error accessing the service"); //Clearing the error ServicesModel.Error = null; //Reenabling submit and disabling refresh _canSubmit = true; _canRefresh = false; return; } if (feed != null) { //Creating a temporary collection on the worker thread to avoid cross-thread exceptions. //This will keep the UI responsive while the thread iterates over the document list. ObservableCollection <string> temp = new ObservableCollection <string>(); foreach (var entry in feed.Entries) { temp.Add(entry.Title.Text); } //Assiging this collection to the Data collection bound to the View. Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { Data = temp; })); } }
public ActionResult EditService(int id) { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; ServicesModel model = new ServicesModel(); ServicesDataService dataservice = new ServicesDataService(); try { model = dataservice.GetServicesModelByServiceId(id); return(View(model)); } catch (Exception ex) { throw ex; } finally { model = null; dataservice = null; } }
// GET: Client/Home // GET: Admin/Home public ActionResult Index() { string UserId = Session["UserId"].ToString(); //Start Search balance from userid Session["Balance"] = _walletUser.UserInfo(UserId).Balance.ToString(); //Ends var lst = _services.GetServicesList(UserId).MapObjects <ServicesModel>(); List <ServicesModel> servicesModels = new List <ServicesModel>(); foreach (var item in lst) { ServicesModel model = new ServicesModel(); model.ProductId = item.ProductId.EncryptParameter(); model.ProductLogo = item.ProductLogo; model.ProductLabel = item.ProductLabel; model.ProductCategory = item.ProductCategory; model.ClientPmtUrl = string.IsNullOrEmpty(item.ProductUrl) ? item.ClientPmtUrl : item.ProductUrl; model.CommissionValue = item.CommissionValue; model.CommissionType = item.CommissionType; model.Company = item.Company; model.Status = item.Status.Trim();//== "Y" ? "checked" : ""; servicesModels.Add(model); } return(View(servicesModels)); //return View(); }
public int AddService(ServicesModel objSerive, HttpPostedFileBase file) { if (file != null) { MemoryStream target = new MemoryStream(); file.InputStream.CopyTo(target); objSerive.Image = target.ToArray(); } objSerive.CreatedDate = DateTime.Now.Date; objSerive.UpdatedDate = DateTime.Now.Date; objSerive.IsActive = true; using (PhysioDevEntities db = new PhysioDevEntities()) { try { Service service = new Service(); objSerive.CopyProperties(service); db.Services.Add(service); db.SaveChanges(); return(1); } catch (DbEntityValidationException ex) { return(0); throw ex; } } }
public static int Insert(ServicesModel model) { try { using (DataContentDataContext dc = new DataContentDataContext()) { Service newItem = new Service(); newItem.Id = model.ID; newItem.Header = model.Header; newItem.Name = model.Name; newItem.Descrition = model.Descrition; newItem.Link_Image = model.Link_Image; newItem.Link_Image_Small = model.Link_Image_Small; newItem.Price = model.Price; newItem.Type_Services = model.Type_Services; newItem.Creater = model.Creater; newItem.CreateDate = model.CreateDate; newItem.Modifier = model.Modifier; newItem.ModifyDate = model.ModifyDate; dc.Services.InsertOnSubmit(newItem); dc.SubmitChanges(); } return 1; } catch (Exception) { return 0; } }
public async Task <IActionResult> ShopServices(ServicesModel servicesModel) { if (ModelState.IsValid) { ShopServicesDb services = new ShopServicesDb { ServiceName = servicesModel.ServiceName, UserId = int.Parse(Request.Cookies["UserID"]), ServiceCost = servicesModel.ServiceCost, ServiceDescription = servicesModel.ServiceDescription, }; bool result = await _repo.CreateShopServices(services); if (result) { ViewBag.ServiceSuccess = $"A new Service Have been Added {services.ServiceName}"; // return RedirectToAction("ShopServices", "Account"); } else { ModelState.AddModelError(string.Empty, "Couldn't Add Shop Services. Try Again With Cookies Enabled"); } } return(View(servicesModel)); }
public List <ServicesModel> GenerateServiceModelByServicesIds(int[] servicesIds) { try { List <ServicesModel> modelList = new List <ServicesModel>(); ServicesModel model = new ServicesModel(); foreach (var item in servicesIds) { using (VenturadaDataContext vdc = new VenturadaDataContext()) { var tableList = from p in vdc.Services.ToList() where p.ServicesId == (int)item select p; model = new ServicesModel(); model.ServicesId = tableList.FirstOrDefault().ServicesId; model.ServiceName = tableList.FirstOrDefault().ServiceName; model.ServiceSubTitle = tableList.FirstOrDefault().ServiceSubTitle; model.ServiceDescription = tableList.FirstOrDefault().ServiceDescription; model.ImageString = tableList.FirstOrDefault().ImageString; } modelList.Add(model); } return(modelList); } catch (Exception ex) { throw ex; } }
public IActionResult Index(string categoryName) { ViewBag.CurrentPage = "Services"; Page currentService; ServicesModel model = new ServicesModel(); model.services = _services; if (categoryName != null) { currentService = _services.Find(x => x.UrlName == categoryName); } else { try { currentService = _services[0]; } catch { currentService = new Page(); } } model.currentService = currentService; model.tags = _tagService.GetAll(currentService.Id); return(View(model)); }
public IActionResult UpdateAvailableService([FromBody] ServicesModel ServicesModel) { string Action = "Update"; //string connectionString = configuration.GetSection("ConnectionString").GetSection("DefaultConnection").Value; //List<VehicleServiceHistoryDetails> vechileList = new List<VehicleServiceHistoryDetails>(); try { int row = GetSaveAvailableService(ServicesModel, Action); //Data.ServiceAvailability.SaveAvailableService(ServicesModel, Action); if (row > 0) { return(StatusCode((int)HttpStatusCode.OK, "Updated Successfully")); } else { return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "Error while Updating the Service" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("UpdateAvailableService", e.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message.ToString() } })); } }
public ActionResult UpdaterLimit(ServicesModel model) { UpdateLimit(model.Service_id, model.Limit); return(RedirectToAction("ViewServices")); }
public ServicesModel GetServicesModelByServiceId(int id) { ServicesModel model = new ServicesModel(); try { using (VenturadaDataContext vdc = new VenturadaDataContext()) { var tableList = from p in vdc.Services.ToList() where p.ServicesId == id select p; model = new ServicesModel(); model.ServicesId = tableList.FirstOrDefault().ServicesId; model.ServiceName = tableList.FirstOrDefault().ServiceName; model.ServiceSubTitle = tableList.FirstOrDefault().ServiceSubTitle; model.ServiceDescription = tableList.FirstOrDefault().ServiceDescription; model.ImageString = tableList.FirstOrDefault().ImageString; return(model); } } catch (Exception ex) { throw ex; } }
public ActionResult Edit(ServicesModel modifiedModel, string FILTER_Keyword, int?FILTER_Active) { if (ModelState.IsValid) { if (isExists(modifiedModel.Id, modifiedModel.Name)) { ModelState.AddModelError(ServicesModel.COL_Name.Name, $"{modifiedModel.Name} sudah terdaftar"); } else { ServicesModel originalModel = get(modifiedModel.Id); string log = string.Empty; log = Helper.append(log, originalModel.Name, modifiedModel.Name, ServicesModel.COL_Name.LogDisplay); log = Helper.append(log, originalModel.Active, modifiedModel.Active, ServicesModel.COL_Active.LogDisplay); log = Helper.append(log, originalModel.Notes, modifiedModel.Notes, ServicesModel.COL_Notes.LogDisplay); log = Helper.append(log, originalModel.Description, modifiedModel.Description, ServicesModel.COL_Description.LogDisplay); log = Helper.append <UnitsModel>(log, originalModel.Units_Id, modifiedModel.Units_Id, ServicesModel.COL_Units_Id.LogDisplay); log = Helper.append(log, originalModel.ForSale, modifiedModel.ForSale, ServicesModel.COL_ForSale.LogDisplay); log = Helper.append(log, originalModel.SellPrice, modifiedModel.SellPrice, ServicesModel.COL_SellPrice.LogDisplay); if (!string.IsNullOrEmpty(log)) { update(modifiedModel, log); } return(RedirectToAction(nameof(Index), new { FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active })); } } setViewBag(FILTER_Keyword, FILTER_Active); return(View(modifiedModel)); }
public void BindData() { string Id = Request.QueryString["id"]; ServicesModel model = new ServicesModel(); model.ID = Id; objService = ServicesViewModel.SelectOne(model); }
public ActionResult GetServices() { ServicesModel model = new ServicesModel(); var userService = reg.Userservices(User.Identity.GetUserId()).ToList(); model.services = userService; return(View(model)); }
public ActionResult Edit([Bind(Include = "serviceID,serviceName")] ServicesModel servicesModel) { if (ModelState.IsValid) { sl.edit(servicesModel); return(RedirectToAction("Index")); } return(View(servicesModel)); }
public ServicesModel GetServices(int locationId, InvoiceModel invoice) { ServicesModel model = new ServicesModel(); model.AvailableLabor = GetAvailableLaborTypes(invoice); model.AvailableServices = GetAvailableServiceTypes(invoice); model.SignedInEmployees = GetSignedInEmployees(locationId); return(model); }
async Task GetWeatherAsync(ServicesModel model) { model.AddMessage("Запуск получения погоды"); WeatherClient weatherClient = new WeatherClient(); model.Weather = await weatherClient.GetWeatherInfoAsync(); model.AddMessage("Завершение получения погоды"); }
async Task GetLastNewsAsync(ServicesModel model) { model.AddMessage("Запуск получения новостей"); NewsClient newsClient = new NewsClient(); model.News = await newsClient.GetNewsAsync(); model.AddMessage("Завершение получения новостей"); }
public ActionResult Create([Bind(Include = "ServiceName,ShortDesc,LongDesc,IsActive,Priority")] ServicesModel service, HttpPostedFileBase file) { int retvalue = _IService.AddService(service, file); if (retvalue > 0) { return(RedirectToAction("Index")); } return(View(service)); }
protected void lbtnDelete_Command(object sender, CommandEventArgs e) { try { ServicesModel model = new ServicesModel(); model.ID = e.CommandArgument.ToString(); ServicesViewModel.Delete(model); } catch (Exception) { lblError.Text = "Lỗi hệ thống!"; } }
public void SaveService() { ServicesModel model = new ServicesModel(); model.ID = txtId.Text; model.Name = txtName.Text; model.Price = txtPrice.Text; model.Type_Services = (cmdSerType.SelectedValue != "")?cmdSerType.SelectedValue.ToCharArray()[0]:'0'; model.Header = FTBHeader.Text; model.Descrition = FTBContents.Text; model.Link_Image_Small = UploadImage(imgSmall, "small"); model.Link_Image = UploadImage(imgBig, "big"); model.Creater = Session["user"].ToString(); model.CreateDate = DateTime.Now.ToString("yyyyMMdd"); ServicesViewModel.Insert(model); }
public void UpdateService() { ServicesModel model = new ServicesModel(); model.ID = txtId.Text; model.Name = txtName.Text; model.Price = txtPrice.Text; model.Type_Services = (cmdSerType.SelectedValue != "") ? cmdSerType.SelectedValue.ToCharArray()[0] : '0'; model.Header = FTBHeader.Text; model.Descrition = FTBContents.Text; model.Link_Image_Small = (imgSmall.FileName != null) ? UploadImage(imgSmall, "small") : showImgSmall.ImageUrl; model.Link_Image = (imgBig.FileName != "") ? UploadImage(imgBig, "big") : showImageBig.ImageUrl; model.Modifier = Session["user"].ToString(); model.ModifyDate = DateTime.Now.ToString("yyyyMMdd"); ServicesViewModel.Update(model); }
public void getDateEdit() { ServicesModel model = new ServicesModel(); model.ID = Request.QueryString["id"]; if (model.ID != "") { model = ServicesViewModel.SelectOne(model); txtId.Text = model.ID; txtName.Text = model.Name; txtPrice.Text = model.Price; cmdSerType.SelectedValue = model.Type_Services.ToString(); showImgSmall.ImageUrl = model.Link_Image_Small; showImageBig.ImageUrl = model.Link_Image; FTBHeader.Text = model.Header; FTBContents.Text = model.Descrition; } }
public static int Delete(ServicesModel model) { try { using (DataContentDataContext dc = new DataContentDataContext()) { Service delItem = dc.Services.Where(a => a.Id == model.ID).SingleOrDefault(); dc.Services.DeleteOnSubmit(delItem); dc.SubmitChanges(); } return 1; } catch (Exception) { return 0; } }
public static int Update(ServicesModel model) { try { using (DataContentDataContext dc = new DataContentDataContext()) { Service changeItem = dc.Services.Where(a => a.Id == model.ID).SingleOrDefault(); changeItem.Header = model.Header; changeItem.Descrition = model.Descrition; changeItem.Name = model.Name; changeItem.Price = model.Price; changeItem.Type_Services = model.Type_Services; changeItem.Link_Image = model.Link_Image; changeItem.Link_Image_Small = model.Link_Image_Small; changeItem.ModifyDate = model.ModifyDate; changeItem.Modifier = model.Modifier; dc.SubmitChanges(); } return 1; } catch (Exception) { return 0; } }
public static ServicesModel SelectOne(ServicesModel model) { try { using (DataContentDataContext dc = new DataContentDataContext()) { Service i = dc.Services.Where(a => a.Id == model.ID).SingleOrDefault(); return new ServicesModel(i.Id, i.Header, i.Name, i.Descrition, i.Price, i.Link_Image_Small, i.Link_Image, i.Type_Services, i.Creater, i.CreateDate, i.Modifier, i.ModifyDate); } } catch (Exception) { return new ServicesModel(); } }
public bool checkService(string strWhere) { this.sm = new ServicesDal(); this.dbo = new DB_OPT(); return (this.sm.GetList(strWhere, this.dbo).Tables[0].Rows.Count > 0); }
/// <summary> /// Select top Like service. /// </summary> /// <returns></returns> public static ServicesModel SelectTopLikeService() { try { using (DataContentDataContext dc = new DataContentDataContext()) { ServicesModel s = null; var items = (from sv in dc.Services select sv); int count = items.Count(); // 1st round-trip int index = new Random().Next(count); var result = items.Skip(index).Take(1); foreach (var i in result) { s = new ServicesModel(i.Id, i.Header, i.Name, i.Descrition, i.Price, i.Link_Image_Small, i.Link_Image, i.Type_Services, i.Creater, i.CreateDate, i.Modifier, i.ModifyDate); } return s; } } catch (Exception) { return new ServicesModel(); } }
private void GetTopLike() { topLike = ServicesViewModel.SelectTopLikeService(); }
private void GetTopView() { topView = ServicesViewModel.SelectTopViewService(); }
/// <summary> /// Select Top service to view in default page /// </summary> /// <returns></returns> public static List<ServicesModel> SelectTopService(int top) { List<ServicesModel> lst = new List<ServicesModel>(); try { using (DataContentDataContext dc = new DataContentDataContext()) { var items = (from temp in dc.Services select temp).Take(top); foreach (var i in items) { ServicesModel n = new ServicesModel(i.Id, i.Header, i.Name, i.Descrition, i.Price, i.Link_Image_Small, i.Link_Image, i.Type_Services, i.Creater, i.CreateDate, i.Modifier, i.ModifyDate); lst.Add(n); } } return lst; } catch (Exception) { return lst; } }
/// <summary> /// Select top view service. /// </summary> /// <returns></returns> public static ServicesModel SelectTopViewService() { try { using (DataContentDataContext dc = new DataContentDataContext()) { ServicesModel s = null; var items = dc.Services.Where(a => a.ServiceView == getMaxView()).Take(1); foreach (var i in items) { s = new ServicesModel(i.Id, i.Header, i.Name, i.Descrition, i.Price, i.Link_Image_Small, i.Link_Image, i.Type_Services, i.Creater, i.CreateDate, i.Modifier, i.ModifyDate); } return s; } } catch (Exception) { return new ServicesModel(); } }