public ActionResult Registration(Registration registration) { if (registration.RegistrationId == -1) { registration.IsActive = true; dbContext.Registrations.Add(registration); dbContext.SaveChanges(); } else { Registration regObj = dbContext.Registrations.Where(x => x.RegistrationId == registration.RegistrationId).FirstOrDefault(); if (regObj != null) { regObj.OracleDataBase = registration.OracleDataBase; regObj.Payment1 = registration.Payment1; regObj.Payment2 = registration.Payment2; regObj.Product = registration.Product; regObj.StartDate = registration.StartDate; regObj.TrainerName = registration.TrainerName; regObj.Email = registration.Email; regObj.Amount = registration.Amount; regObj.Balance = registration.Balance; regObj.CompanyName = registration.CompanyName; regObj.Contact = registration.Contact; regObj.CourseName = registration.CourseName; regObj.VAT = registration.VAT; regObj.WHT = registration.WHT; //regObj. = registration.CompanyName; } dbContext.SaveChanges(); } return(RedirectToAction("GetRegistrationList")); }
public JsonResult SaveRevenueInfo(Revenue revenue) { revenue.Year = revenue.Year == 0 ? DateTime.Now.Year : revenue.Year; revenue.HalfYearlyTarget = revenue.YearlyTarget / 2; revenue.QuarterlyTarget = revenue.YearlyTarget / 4; revenue.MonthlyTarget = revenue.YearlyTarget / 12; revenue.YearlyTargetAmt = revenue.YearlyTarget * revenue.CurrencyExRate; revenue.HalfYearlyTargetAmt = revenue.YearlyTargetAmt / 2; revenue.QuarterlyTargetAmt = revenue.YearlyTargetAmt / 4; revenue.MonthlyTargetAmt = revenue.YearlyTargetAmt / 12; revenue.IsActive = true; try { if (revenue.RevenueId == -1) { revenue.CreatedBy = USER_ID; revenue.CreatedOn = UTILITY.SINGAPORETIME; dbContext.Revenues.Add(revenue); } else { Revenue revenueInfo = dbContext.Revenues. Where(x => x.RevenueId == revenue.RevenueId).FirstOrDefault(); revenueInfo.CurrencyExRate = revenue.CurrencyExRate; revenueInfo.YearlyTarget = revenue.YearlyTarget; revenueInfo.HalfYearlyTarget = revenue.HalfYearlyTarget; revenueInfo.QuarterlyTarget = revenue.QuarterlyTarget; revenueInfo.MonthlyTarget = revenue.MonthlyTarget; revenueInfo.YearlyTargetAmt = revenue.YearlyTargetAmt; revenueInfo.HalfYearlyTargetAmt = revenue.HalfYearlyTargetAmt; revenueInfo.QuarterlyTargetAmt = revenue.QuarterlyTargetAmt; revenueInfo.MonthlyTargetAmt = revenue.MonthlyTargetAmt; revenueInfo.IsActive = true; revenueInfo.ModifiedBy = USER_ID; revenueInfo.ModifiedOn = UTILITY.SINGAPORETIME; dbContext.Entry(revenueInfo).State = EntityState.Modified; } dbContext.SaveChanges(); } catch (Exception ex) { throw ex; } string message = "Saved Successfully."; return(Json(message, JsonRequestBehavior.AllowGet)); }
public ActionResult Payment(CustomerPaymentVM customerPaymentVM) { if (customerPaymentVM.CustomerId == -1) { CustomerPayment customerPayment = new CustomerPayment(); customerPayment.BalanceAmount = customerPaymentVM.BalanceAmount; customerPayment.CourseName = customerPaymentVM.CourseName; customerPayment.CustomerName = customerPaymentVM.CustomerName; customerPayment.DueDate = customerPaymentVM.DueDate; customerPayment.InvoiceValue = customerPaymentVM.InvoiceValue; customerPayment.OrderId = customerPaymentVM.OrderId; customerPayment.OtherRecievables = customerPaymentVM.OtherRecievables; customerPayment.PaidAmount = customerPaymentVM.PaidAmount; customerPayment.RecieptDate = customerPaymentVM.RecieptDate; customerPayment.IsActive = true; if (customerPaymentVM.ReferenceDocument.ContentLength > 0) { customerPayment.ReferenceDocument = customerPaymentVM.ReferenceDocument.FileName; string fileName = customerPaymentVM.ReferenceDocument.FileName; string path = Path.Combine(Server.MapPath("~/FileUploads"), fileName); customerPaymentVM.ReferenceDocument.SaveAs(path); } dbContext.CustomerPayments.Add(customerPayment); dbContext.SaveChanges(); } else { CustomerPayment customerPayment = dbContext.CustomerPayments. Where(x => x.CustomerId == customerPaymentVM.CustomerId).FirstOrDefault(); customerPayment.BalanceAmount = customerPaymentVM.BalanceAmount; customerPayment.CourseName = customerPaymentVM.CourseName; customerPayment.CustomerName = customerPaymentVM.CustomerName; customerPayment.DueDate = customerPaymentVM.DueDate; customerPayment.InvoiceValue = customerPaymentVM.InvoiceValue; customerPayment.OrderId = customerPaymentVM.OrderId; customerPayment.OtherRecievables = customerPaymentVM.OtherRecievables; customerPayment.PaidAmount = customerPaymentVM.PaidAmount; customerPayment.RecieptDate = customerPaymentVM.RecieptDate; customerPayment.ReferenceDocument = customerPaymentVM.ReferenceDocument.FileName; dbContext.SaveChanges(); } return(RedirectToAction("CustomerPaymentList")); }
public HttpResponseMessage put(int id, EDUCATION education) { try { using (EducationEntities entities = new EducationEntities()) { var entity = entities.EDUCATION.FirstOrDefault(e => e.EducationId == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Education doesnt exist")); } else { entity.EducationId = education.EducationId; entity.EmployeeId = education.EmployeeId; entity.DocumentId = education.DocumentId; entity.Degree = education.Degree; entity.Institution = education.Institution; entity.StartYear = education.StartYear; entity.EndYear = education.EndYear; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public ActionResult SaveTrainer(TrainerVM TrainerInfo) { if (TrainerInfo.TrainerInformation.TrianerId == -1) { TrainerInformation ti = new TrainerInformation(); ti.TrainerName = TrainerInfo.TrainerInformation.TrainerName; ti.Address = TrainerInfo.TrainerInformation.Address; ti.Contact = TrainerInfo.TrainerInformation.Contact; ti.Country = TrainerInfo.TrainerInformation.Country; if (TrainerInfo.TrainerInformation.Profile.ContentLength > 0) { ti.Profile = TrainerInfo.TrainerInformation.Profile.FileName; string fileName = Path.GetFileName(TrainerInfo.TrainerInformation.Profile.FileName); string path = Path.Combine(Server.MapPath("~/FileUploads"), ti.Profile); TrainerInfo.TrainerInformation.Profile.SaveAs(path); } ti.Remarks = TrainerInfo.TrainerInformation.Remarks; ti.Technology = TrainerInfo.TrainerInformation.Technology; ti.TrainerRate = TrainerInfo.TrainerInformation.TrainerRate; ti.VendorName = TrainerInfo.TrainerInformation.VendorName; ti.IsActive = true; dbContext.TrainerInformations.Add(ti); dbContext.SaveChanges(); } else { TrainerInformation trainerInfoDetail = dbContext.TrainerInformations. Where(x => x.TrianerId == TrainerInfo.TrainerInformation.TrianerId).FirstOrDefault(); if (trainerInfoDetail != null) { trainerInfoDetail.TrainerName = TrainerInfo.TrainerInformation.TrainerName; trainerInfoDetail.Address = TrainerInfo.TrainerInformation.Address; trainerInfoDetail.Contact = TrainerInfo.TrainerInformation.Contact; trainerInfoDetail.Country = TrainerInfo.TrainerInformation.Country; trainerInfoDetail.Profile = TrainerInfo.TrainerInformation.Profile.FileName; trainerInfoDetail.Remarks = TrainerInfo.TrainerInformation.Remarks; trainerInfoDetail.Technology = TrainerInfo.TrainerInformation.Technology; trainerInfoDetail.TrainerRate = TrainerInfo.TrainerInformation.TrainerRate; trainerInfoDetail.VendorName = TrainerInfo.TrainerInformation.VendorName; } dbContext.SaveChanges(); } return(RedirectToAction("TrainersList")); }
public HttpResponseMessage post([FromBody] EDUCATION education) { try { using (EducationEntities entities = new EducationEntities()) { entities.EDUCATION.Add(education); entities.SaveChanges(); HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, education); message.Headers.Location = new Uri(Request.RequestUri + education.EducationId.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage delete(int id) { try { using (EducationEntities entities = new EducationEntities()) { var entity = entities.EDUCATION.FirstOrDefault(e => e.EducationId == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Education doesnt exist")); } else { entities.EDUCATION.Remove(entity); entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }