public async Task <JsonResult> Delete(int Id) { Login Obj = await Task.Run(() => db.Logins.Find(Id)); if (Obj != null) { if (Obj.Flag == "A") { Obj.Flag = "D"; } else { Obj.Flag = "A"; } Obj.UpdateDate = GetCurrentSession.CurrentDateTime(); Obj.UpdateUser = (int)GetCurrentSession.CurrentUser(); await Task.Run(() => db.Entry(Obj).State = System.Data.Entity.EntityState.Modified); await Task.Run(() => db.SaveChanges()); //await Task.Run(() => db.Logines.Remove(Obj)); //await Task.Run(() => db.SaveChanges()); } return(Json(Obj, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> Create(LoginVM loginVM) { var loginResult = new LoginResult(); loginResult.IsError = false; loginResult.ErrorMessage = ""; Login LoginObj = new Login(); var loginList = await Task.Run(() => db.Logins.ToList()); bool Emailexists = false; if (loginVM.LoginID == 0) { var dagtaExists = loginList.Where(t => t.Email == loginVM.Email).FirstOrDefault(); if (dagtaExists != null) { Emailexists = true; loginResult.IsError = true; loginResult.ErrorMessage = "User Name already exits"; } if (!Emailexists) { LoginObj.LoginID = loginVM.LoginID; LoginObj.FirstName = loginVM.FirstName; LoginObj.LoginID = loginVM.LoginID; LoginObj.FirstName = loginVM.FirstName; LoginObj.LastName = loginVM.LastName; LoginObj.RoleID = (int)loginVM.RoleID; LoginObj.Email = loginVM.Email; LoginObj.Password = loginVM.Password; LoginObj.CreateDate = GetCurrentSession.CurrentDateTime(); LoginObj.CreateUser = (int)GetCurrentSession.CurrentUser(); LoginObj.Flag = "A"; await Task.Run(() => db.Logins.Add(LoginObj)); await Task.Run(() => db.SaveChanges()); } } else { LoginObj = await Task.Run(() => db.Logins.Where(t => t.LoginID == loginVM.LoginID).FirstOrDefault()); if (LoginObj != null) { LoginObj.FirstName = loginVM.FirstName; LoginObj.LastName = loginVM.LastName; LoginObj.RoleID = (int)loginVM.RoleID; LoginObj.Flag = "A"; LoginObj.UpdateDate = GetCurrentSession.CurrentDateTime(); LoginObj.UpdateUser = (int)GetCurrentSession.CurrentUser(); await Task.Run(() => db.Entry(LoginObj).State = System.Data.Entity.EntityState.Modified); await Task.Run(() => db.SaveChanges()); } } return(Json(loginResult, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> Create(PickUpBoyVM pickUpVM) { var loginResult = new LoginResult(); loginResult.IsError = false; loginResult.ErrorMessage = ""; var PickUpBoyList = await Task.Run(() => db.PickUpBoys.ToList()); var exits = PickUpBoyList.FirstOrDefault(t => t.PickUpBoyName == pickUpVM.PickUpBoyName && t.PickUpBoyNumber == pickUpVM.PickUpBoyNumber); if (exits != null) { loginResult.IsError = true; loginResult.ErrorMessage = "Data already exists"; } else { PickUpBoy pickUpObj = new PickUpBoy(); if (pickUpVM.PickUpBoyID == 0) { pickUpObj.PickUpBoyName = pickUpVM.PickUpBoyName; pickUpObj.PickUpBoyNumber = (decimal)pickUpVM.PickUpBoyNumber; pickUpObj.CreateDate = GetCurrentSession.CurrentDateTime(); pickUpObj.CreateUser = (int)GetCurrentSession.CurrentUser(); pickUpObj.Flag = "A"; await Task.Run(() => db.PickUpBoys.Add(pickUpObj)); await Task.Run(() => db.SaveChanges()); } else { pickUpObj = await Task.Run(() => db.PickUpBoys.Find(pickUpVM.PickUpBoyID)); if (pickUpObj != null) { { pickUpObj.PickUpBoyName = pickUpVM.PickUpBoyName; pickUpObj.PickUpBoyNumber = (decimal)pickUpVM.PickUpBoyNumber; pickUpObj.UpdateDate = GetCurrentSession.CurrentDateTime(); pickUpObj.UpdateUser = (int)GetCurrentSession.CurrentUser(); pickUpObj.Flag = "A"; await Task.Run(() => db.Entry(pickUpObj).State = System.Data.Entity.EntityState.Modified); await Task.Run(() => db.SaveChanges()); } } } } return(Json(loginResult, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> Create(BusVM busVM) { var loginResult = new LoginResult(); loginResult.IsError = false; loginResult.ErrorMessage = ""; var busList = await Task.Run(() => db.Buses.ToList()); var exits = busList.FirstOrDefault(t => t.BusName == busVM.BusName && t.BusNumber == busVM.BusNumber); if (exits != null) { loginResult.IsError = true; loginResult.ErrorMessage = "Data already exists"; } else { Bus busObj = new Bus(); if (busVM.BusID == 0) { busObj.BusName = busVM.BusName; busObj.BusNumber = busVM.BusNumber; busObj.CreateDate = GetCurrentSession.CurrentDateTime(); busObj.CreateUser = (int)GetCurrentSession.CurrentUser(); busObj.Flag = "A"; await Task.Run(() => db.Buses.Add(busObj)); await Task.Run(() => db.SaveChanges()); } else { busObj = await Task.Run(() => db.Buses.Find(busVM.BusID)); if (busObj != null) { busObj.BusID = busVM.BusID; busObj.BusName = busVM.BusName; busObj.BusNumber = busVM.BusNumber; busObj.Flag = "A"; busObj.UpdateDate = GetCurrentSession.CurrentDateTime(); busObj.UpdateUser = (int)GetCurrentSession.CurrentUser(); await Task.Run(() => db.Entry(busObj).State = System.Data.Entity.EntityState.Modified); await Task.Run(() => db.SaveChanges()); } } } return(Json(loginResult, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> Create(CityVM cityVM) { var loginResult = new LoginResult(); loginResult.IsError = false; loginResult.ErrorMessage = ""; var cityList = await Task.Run(() => db.Cities.ToList()); var exits = cityList.FirstOrDefault(t => t.CityName == cityVM.CityName); if (exits != null) { loginResult.IsError = true; loginResult.ErrorMessage = "Data already exists"; } else { City cityObj = new City(); if (cityVM.CityID == 0) { cityObj.CityName = cityVM.CityName; cityObj.CreateDate = GetCurrentSession.CurrentDateTime(); cityObj.CreateUser = (int)GetCurrentSession.CurrentUser(); cityObj.Flag = "A"; await Task.Run(() => db.Cities.Add(cityObj)); await Task.Run(() => db.SaveChanges()); } else { cityObj = await Task.Run(() => db.Cities.Find(cityVM.CityID)); if (cityObj != null) { cityObj.CityID = cityVM.CityID; cityObj.CityName = cityVM.CityName; cityObj.Flag = "A"; cityObj.UpdateDate = GetCurrentSession.CurrentDateTime(); cityObj.UpdateUser = (int)GetCurrentSession.CurrentUser(); await Task.Run(() => db.Entry(cityObj).State = System.Data.Entity.EntityState.Modified); await Task.Run(() => db.SaveChanges()); } } } return(Json(loginResult, JsonRequestBehavior.AllowGet)); }
public ActionResult Te() { int Tempoid = 1; DateTime CurrentDate = new DateTime(); CurrentDate = GetCurrentSession.CurrentDateTime(); #region Print string joindata = string.Join(", ", "1,2,3"); SqlParameter param1 = new SqlParameter("@Var", joindata); List <rptCustomer> rptCustomerList = db.Database.SqlQuery <rptCustomer>("SP_PickUpboy @Var", param1).ToList(); var LoginList = db.Logins.ToList(); string PrintBy = string.Empty; int CurrentUser = (int)GetCurrentSession.CurrentUser(); var login = LoginList.FirstOrDefault(t => t.LoginID == CurrentUser); if (login != null) { PrintBy = login.FirstName + " " + login.LastName; } //List<rptCustomer> rptCustomerList = context.Database.SqlQuery<rptCustomer>("SP_PickUpboy @Var", param1).ToList<rptCustomer>(); DataTable dtBoyName = new DataTable(); dtBoyName.Columns.Add("Name", typeof(string)); var boy = db.PickUpBoys.FirstOrDefault(t => t.PickUpBoyID == Tempoid); if (boy != null) { dtBoyName.Rows.Add("Delivery Boy:- " + boy.PickUpBoyName + "\t Print By:- " + PrintBy); } else { dtBoyName.Rows.Add(""); } DataTable dtCustomer = new DataTable(); dtCustomer.Columns.Add("LRNo", typeof(string)); dtCustomer.Columns.Add("CustomerName", typeof(string)); dtCustomer.Columns.Add("PayTypeStatus", typeof(string)); dtCustomer.Columns.Add("Amount", typeof(decimal)); dtCustomer.Columns.Add("Total", typeof(decimal)); dtCustomer.Columns.Add("Damrage", typeof(decimal)); dtCustomer.Columns.Add("Hamali", typeof(decimal)); dtCustomer.Columns.Add("NoOfParcel", typeof(int)); dtCustomer.Columns.Add("CustomerNumber", typeof(string)); foreach (var item in rptCustomerList) { dtCustomer.Rows.Add(item.LRNo, item.CustomerName, item.PayTypeStatus, item.Amount, item.Total, item.Damrage, item.Hamali * item.NoOfParcel, item.NoOfParcel, item.CustomerNumber); } DataSet1 myds = new DataSet1(); myds.Tables["DtPickupBoy"].Merge(dtCustomer); myds.Tables["DtBoyName"].Merge(dtBoyName); ReportDocument rptH = new ReportDocument(); rptH.Load(Server.MapPath("~/Reports/rptPickUpboy.rpt")); rptH.SetDataSource(myds); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string path = Server.MapPath("~/PDF"); AllClass.CreateDirectory(path); string fileName = path + "/" + htmlfilename + ".pdf"; string fileName2 = htmlfilename + ".pdf"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } rptH.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, fileName); JsonResult result = new JsonResult(); result.Data = fileName2; return(result); #endregion }