public string UserLogin([FromBody] JObject request) { if (request != null) { var user = JsonConvert.DeserializeObject <User>(request.ToString()); using (CarSystemEntities db = new CarSystemEntities()) { var userDetails = db.Users.FirstOrDefault(u => u.EmployeeId == user.UserId && u.Password == user.Password && u.Status == "Active" && u.CompanyId == user.CompanyId); if (userDetails != null) //User was found { var result = db.prGetUsers(userDetails.Id, userDetails.Id, "Single").ToList(); var result1 = Newtonsoft.Json.JsonConvert.SerializeObject(result, Newtonsoft.Json.Formatting.Indented); return(result1); } else //User was not found { var result = Newtonsoft.Json.JsonConvert.SerializeObject(null, Newtonsoft.Json.Formatting.Indented); return(result); } } } else { var result = Newtonsoft.Json.JsonConvert.SerializeObject(null, Newtonsoft.Json.Formatting.Indented); return(result); } return(""); }
public HttpResponseMessage PostDailyCarLog([FromBody] JObject request) { if (request != null) { var DCarLog = JsonConvert.DeserializeObject <DailyCarHistory>(request.ToString()); try { //DateTime checkIn = null; // DCarLog.CheckInDate==null?null: Datetime.Parse(DCarLog.CheckOutDate); // var dat2 = Convert.ToDateTime(DCarLog.CheckOutDate); using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prSaveDailyCarLog(DCarLog.CarLogId, DCarLog.CarId, DCarLog.DriverId, DCarLog.RootId, DCarLog.CheckInDate, DCarLog.CheckOutDate, DCarLog.CheckInTime, DCarLog.CheckOutTime, DCarLog.TripNo, DCarLog.TotalDistance, Convert.ToInt32(DCarLog.CheckInBy), Convert.ToInt32(DCarLog.CheckOutBy), DCarLog.CreatedBy, DCarLog.IsUnwantedReturn, DCarLog.ReasonForReturn, DCarLog.Status, DCarLog.Update, DCarLog.RouteStartPoint, DCarLog.ExceptioalAmount, DCarLog.TripType, DCarLog.DifferentRouteIncome, DCarLog.DifferentRouteDistance, DCarLog.AdditionalIncomeType, DCarLog.IsUnOfficialDay).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, returnData.ToString())); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save driver information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }
public HttpResponseMessage PostRolePermission([FromBody] JArray request, int RoleId, int UserId, int CompanyId) { if (request != null) { var RolePermission = JsonConvert.DeserializeObject <prGetMenuListRoleWise_Result[]>(request.ToString()); try { using (CarSystemEntities db = new CarSystemEntities()) { db.Database.ExecuteSqlCommand("Delete from Menupermission Where RoleId=" + RoleId + " AND CompanyId=" + CompanyId); foreach (prGetMenuListRoleWise_Result permission in RolePermission) { db.Database.ExecuteSqlCommand("Insert into Menupermission (RoleId,MenuId,IsPermit,CompanyId) Values (" + RoleId + "," + permission.MDetailsId + "," + permission.IsPermit + " ," + CompanyId + ")"); } //var returnData = db.prSaveUser(User.Id, User.EmployeeId, User.Name, User.NameInBangla, User.Password, User.Status, User.PresentAddress, User.PermanentAddress, User.RoleId, User.ContactNo, Int32.Parse(User.CreatedBy), User.Update, User.CorpJoinDate == null ? (DateTime?)null : Convert.ToDateTime(User.CorpJoinDate), User.DepotJoinDate == null ? (DateTime?)null : Convert.ToDateTime(User.DepotJoinDate), User.RetirementDate == null ? (DateTime?)null : Convert.ToDateTime(User.RetirementDate), User.DateOfBirth == null ? (DateTime?)null : Convert.ToDateTime(User.DateOfBirth), User.Grade, User.FatherName).FirstOrDefault(); //var returnData = db.prSaveUser(User.Id, User.EmployeeId, User.Name, User.NameInBangla, User.Password, User.Status, User.PresentAddress, User.PermanentAddress, User.RoleId, User.ContactNo, Int32.Parse(User.CreatedBy), User.Update, User.CorpJoinDate == null ? (DateTime?)null : Convert.ToDateTime(User.CorpJoinDate), User.DepotJoinDate == null ? (DateTime?)null : Convert.ToDateTime(User.DepotJoinDate), User.RetirementDate == null ? (DateTime?)null : Convert.ToDateTime(User.RetirementDate), null, User.Grade).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, "Your request successfully saved")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save car type information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }
public HttpResponseMessage PostPayslipForApproval([FromBody] JArray request, int UserId, string Type) { if (request != null) { List <prGetPaySlipDetails_Result> PSlip = JsonConvert.DeserializeObject <prGetPaySlipDetails_Result[]>(request.ToString()).ToList(); try { using (CarSystemEntities db = new CarSystemEntities()) { foreach (prGetPaySlipDetails_Result pSlip in PSlip) { //returnData = db.prSavePaySlip(pSlip.PaySlipId, pSlip.SlipNo, pSlip.BookNo, pSlip.Amount, pSlip.Status, Int32.Parse(pSlip.CreatedBy), pSlip.Update).FirstOrDefault(); db.Database.ExecuteSqlCommand("Update PaySlipBook set Status='Approved', ApprovedBy=" + UserId + " Where PaySlipId=" + pSlip.PaySlipId); } // var returnData = db.prSavePaySlip(PSlip.PaySlipId, PSlip.SlipNo, RCost.CarTypeId, RCost.Cost, RCost.UnofficialCost, RCost.Status, RCost.Notes, RCost.CreatedBy, RCost.Update).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, "Your request successfully executed.")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save pay slip information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }
public HttpResponseMessage PostDailyCarLogOnDemand([FromBody] JArray request, int UserId, string Type) { if (request != null) { User user = _commonService.GetUserById(Convert.ToInt32(UserId)); var DCarLog = JsonConvert.DeserializeObject <DailyCarHistory[]>(request.ToString()); try { // DateTime checkIn = null; // DCarLog.CheckInDate==null?null: Datetime.Parse(DCarLog.CheckOutDate); // var dat2 = Convert.ToDateTime(DCarLog.CheckOutDate); using (CarSystemEntities db = new CarSystemEntities()) { //var returnData = db.prSaveDailyCarLog(DCarLog.CarLogId, DCarLog.CarId, DCarLog.DriverId, DCarLog.RootId, DCarLog.CheckInDate, DCarLog.CheckOutDate, DCarLog.CheckInTime, DCarLog.CheckOutTime, DCarLog.TripNo, DCarLog.TotalDistance, Convert.ToInt32(DCarLog.CheckInBy), Convert.ToInt32(DCarLog.CheckOutBy), DCarLog.CreatedBy, DCarLog.IsUnwantedReturn, DCarLog.ReasonForReturn, DCarLog.Status, DCarLog.Update).FirstOrDefault(); foreach (DailyCarHistory dCarLog in DCarLog) { //returnData = db.prSavePaySlip(pSlip.PaySlipId, pSlip.SlipNo, pSlip.BookNo, pSlip.Amount, pSlip.Status, Int32.Parse(pSlip.CreatedBy), pSlip.Update).FirstOrDefault(); db.Database.ExecuteSqlCommand("Update DailyCarHistories set Status='Approved', ApprovedBy=" + UserId + " Where CarLogId=" + dCarLog.CarLogId); } return(Request.CreateResponse(HttpStatusCode.OK, user.Language == "bn"?"নির্বাচিত গাড়ি গুলো অনুমোদন দেওয়া হয়েছে।": "Your request executed successfully.")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save driver information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }
public PartsUnitOfWork(User user) { _user = user; _context = new CarSystemEntities(); _partsDetailsRepo = new PartsDetailsRepository(_context, _user); _storeInfoRepo = new StoreInfoRepository(_context, _user); }
public HttpResponseMessage PostPayslip([FromBody] JArray request) { if (request != null) { List <prGetPaySlipDetails_Result> PSlip = JsonConvert.DeserializeObject <prGetPaySlipDetails_Result[]>(request.ToString()).ToList(); try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = ""; foreach (prGetPaySlipDetails_Result pSlip in PSlip) { returnData = db.prSavePaySlip(pSlip.PaySlipId, pSlip.SlipNo, pSlip.BookNo, pSlip.Amount, pSlip.Status, Int32.Parse(pSlip.CreatedBy), pSlip.Update).FirstOrDefault(); } // var returnData = db.prSavePaySlip(PSlip.PaySlipId, PSlip.SlipNo, RCost.CarTypeId, RCost.Cost, RCost.UnofficialCost, RCost.Status, RCost.Notes, RCost.CreatedBy, RCost.Update).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, returnData.ToString())); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save pay slip information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }
private bool IsDublicateInOrderDetails(CarSystemEntities db, int modelID, int orderID, IEnumerable <int> accessoriesID) { if (accessoriesID == null) { accessoriesID = new List <int>() { 0 }; } foreach (int accessoryID in accessoriesID) { var dublicatesQuery = from junctionTable in db.OrderDetails join accessory in db.Accessories on junctionTable.AccessoryID equals accessory.ID join model in db.Models on junctionTable.ModelID equals model.ID join order in db.Orders on junctionTable.OrderID equals order.ID where model.ID == modelID && order.ID == orderID && accessory.ID == accessoryID select new { ModelID = junctionTable.ModelID, OrderID = junctionTable.OrderID, AccessoryID = junctionTable.AccessoryID }; if (dublicatesQuery.Any()) { //there would be dublicate record! return(true); } } return(false); }
public HttpResponseMessage postPOL([FromBody] JObject request) { if (request != null) { var polDetails = JsonConvert.DeserializeObject <prGetPol_Result>(request.ToString()); try { using (CarSystemEntities db = new CarSystemEntities()) { var checkInDate = polDetails.CheckInDate == null ? (DateTime?)null : Convert.ToDateTime(polDetails.CheckInDate); var returnData = db.prSavePOLDetails(polDetails.POLId, polDetails.CarId, polDetails.CheckInDate == null ? (DateTime?)null : Convert.ToDateTime(polDetails.CheckInDate), polDetails.DriverId, polDetails.IssuedById, Convert.ToDecimal(polDetails.CNG), Convert.ToDecimal(polDetails.Diesel), Convert.ToDecimal(polDetails.EngineOil), Convert.ToDecimal(polDetails.PowerOil), Convert.ToDecimal(polDetails.GearOil), Convert.ToDecimal(polDetails.Grease), polDetails.Status, polDetails.Remark, polDetails.Createdby, polDetails.Created).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, returnData.ToString())); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }
public HttpResponseMessage PostPayment([FromBody] JObject request) { if (request != null) { var DCarLog = JsonConvert.DeserializeObject <prGetDailyPaymentLog_Result>(request.ToString()); try { //DateTime checkIn = null; // DCarLog.CheckInDate==null?null: Datetime.Parse(DCarLog.CheckOutDate); // var dat2 = Convert.ToDateTime(DCarLog.CheckOutDate); using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prSaveDailyPayment(DCarLog.PaymentId, DCarLog.CarLogId, DCarLog.PaymentAmount, DCarLog.SystemAmount, DCarLog.Notes, DCarLog.PaySlipId, DCarLog.PaymentStatus, DCarLog.ReceivedBy, DCarLog.ReceivedByName, DCarLog.ReceivedDate, DCarLog.Status, Int32.Parse(DCarLog.CreatedBy), DCarLog.Update, DCarLog.PaymentType).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, returnData.ToString())); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save payment information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }
public List <AccessoryVM> GetCarAccessoriesFromOrder(CarSystemEntities db, int?orderID) { var accessoryQuery = from junctionTable in db.OrderDetails where junctionTable.OrderID == orderID join accessory in db.Accessories on junctionTable.AccessoryID equals accessory.ID select new AccessoryVM { Name = accessory.Name, Description = accessory.Description, Price = accessory.Price, ID = accessory.ID }; return(accessoryQuery.ToList()); }
public CarModelVM GetCarModelFromOrder(CarSystemEntities db, int?orderID) { var modelQuery = from junctionTable in db.OrderDetails where junctionTable.OrderID == orderID join model in db.Models on junctionTable.ModelID equals model.ID select new CarModelVM { Name = model.Name, OrderID = orderID, ID = model.ID }; return(modelQuery.FirstOrDefault()); }
public Order MapOrderViewModel(CarSystemEntities db, CreateOrderVM newOrderVM)//Creates Order Entity Model that is saved to the database from Order view model { int newOrderID = newOrderVM.GetHashCode(); DateTime newOrderDate = newOrderVM.OrderDate; decimal newOrderPrice = CalculateOrderPrice(db, newOrderVM.SelectedModelID, newOrderVM.AccessoriesIDs); int newOrderClient = newOrderVM.SelectedClientID; ICollection <OrderDetail> orderDetails = CreateOrderDetailFromOrderVm(newOrderVM.SelectedModelID, newOrderID, newOrderVM.AccessoriesIDs); Order newOrderEM = new Order(newOrderID, newOrderDate, newOrderPrice, newOrderClient, db.Clients.Find(newOrderClient), orderDetails); return(newOrderEM); }
private decimal CalculateOrderPrice(CarSystemEntities db, int modelID, IEnumerable <int> accessoriesID) { decimal orderPrice = db.Models.Find(modelID).Price; if (accessoriesID != null && accessoriesID.Count() > 0) { foreach (var itemID in accessoriesID) { orderPrice += db.Accessories.Find(itemID).Price; } } return(orderPrice); }
public HashSet <CarModelVM> GetAllCarModelFromOrder(CarSystemEntities db) { HashSet <CarModelVM> carsOrdered = new HashSet <CarModelVM>(); foreach (var order in db.Orders) { CarModelVM modelVM = GetCarModelFromOrder(db, order.ID); if (modelVM != null) { carsOrdered.Add(modelVM); } } return(carsOrdered); }
public HttpResponseMessage SpecialActivity(int UserId, int CarLogId, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prSpecialActionOnCarLog(UserId, CarLogId, Type).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, returnData)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System has problem to pull user information.")); } }
public HttpResponseMessage GetDailyPOLLogByDate(int UserId, string Type, DateTime FromDate, DateTime ToDate) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prGetDailyPOLLog(UserId, FromDate, ToDate, 0, Type).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, returnData)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to show list. Please contact with admin.")); } }
public HttpResponseMessage UpdateDilyCarLog(int UserId, int CarLogId, string AdditionalId, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prUpdateDailyCarLog(UserId, CarLogId, AdditionalId, Type).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, returnData)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to show bus log list. Please contact with admin.")); } }
public HttpResponseMessage GetBusesOnType(int UserId, int Id, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prGetCarDetails(UserId, Id, Type).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, returnData)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to show bus list. Please contact with admin.")); } }
public HttpResponseMessage DeletePaySlipBook(int UserId, int PaySlipId, string BookNo, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnresult = db.prDeletePaySlip(UserId, PaySlipId, BookNo, Type).FirstOrDefault();; return(Request.CreateResponse(HttpStatusCode.OK, returnresult)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to delete root cost information. Please try agian.")); } }
public HttpResponseMessage DeleteCarLog(int CarLogId) { try { using (CarSystemEntities db = new CarSystemEntities()) { db.Database.ExecuteSqlCommand("Update DailyCarHistories set Status='Delete' Where DriverId=" + CarLogId); return(Request.CreateResponse(HttpStatusCode.OK, "Driver information has deleted successfully.")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to delete bus log information. Please try agian.")); } }
public HttpResponseMessage GetDailyPaymentReportSection(int UserId, DateTime SelectedDate, int CarTypeId, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnresult = db.prGetDailyPaymentReportSection(UserId, SelectedDate, CarTypeId, Type).ToList();; return(Request.CreateResponse(HttpStatusCode.OK, returnresult)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to show information. Please try agian.")); } }
public HttpResponseMessage GetPaySlipListOnDemandApproval(int UserId, int PaySlipId, string BookNo, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prUpdatePaySlipDetails(UserId, PaySlipId, BookNo, Type).FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, returnData)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to show pay slip list. Please contact with admin.")); } }
public HttpResponseMessage GetMonthlyIncomeReport(int UserId, DateTime FromDate, DateTime ToDate, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnresult = db.prGetMonthlyIncomeReportDateRange(UserId, FromDate, ToDate, Type).ToList();; return(Request.CreateResponse(HttpStatusCode.OK, returnresult)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to delete root cost information. Please try agian.")); } }
public HttpResponseMessage GetDashboardReport(int UserId, DateTime date) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnresult = db.prGetDashboardReport(UserId, date).ToList();; return(Request.CreateResponse(HttpStatusCode.OK, returnresult)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to delete root cost information. Please try agian.")); } }
public HttpResponseMessage GetBusPaymentHistory(int UserId, DateTime FromDate, DateTime ToDate, int RouteId, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnresult = db.prGetBusPaymentHistory(UserId, FromDate, ToDate, RouteId, Type).ToList();; return(Request.CreateResponse(HttpStatusCode.OK, returnresult)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to show information. Please try agian.")); } }
public HttpResponseMessage GetRoles(int UserId) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prGetRoles(UserId).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, returnData)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to show role list. Please contact with admin.")); } }
public HttpResponseMessage GetUserMenuRoleWise(int RoleId) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.prGetMenuListRoleWise(RoleId).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, returnData)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System has problem to pull user information.")); } return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System has problem to pull user information.")); }
public HttpResponseMessage DeleteRole(int RoleId) { try { using (CarSystemEntities db = new CarSystemEntities()) { db.Database.ExecuteSqlCommand("Update Roles set Status='Delete' Where RoleId=" + RoleId); return(Request.CreateResponse(HttpStatusCode.OK, "Role has deleted successfully.")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "System has failed to delete role information. Please contact with admin.")); } }
public HttpResponseMessage UpdateUserInfo(int UserId, string Lang, string Type) { try { using (CarSystemEntities db = new CarSystemEntities()) { var returnData = db.Database.ExecuteSqlCommand("Update Users Set Language='" + Lang + "' Where Id=" + UserId); //var result = Newtonsoft.Json.JsonConvert.SerializeObject(returnData, Newtonsoft.Json.Formatting.Indented); return(Request.CreateResponse(HttpStatusCode.OK, "Successfully updated.")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System has problem to pull user information.")); } }