public static void Update(ScheduleBO schToUpdate) { EstimateDBEntities context = new EstimateDBEntities(); GenericRepository <EstimateScheduled> repo = new GenericRepository <EstimateScheduled>(context); var config = new MapperConfiguration(cfg => cfg.CreateMap <ScheduleBO, EstimateScheduled>()); var mapper = config.CreateMapper(); var schedule = mapper.Map <EstimateScheduled>(schToUpdate); repo.Update(schedule); repo.Save(); }
public ActionResult SaveSchedule(ScheduleBO scheduleEntity) { if (scheduleEntity.EST_SchID != 0 && scheduleEntity.EST_SchID != null) { ScheduleData.Update(scheduleEntity); return(new HttpStatusCodeResult(201, "Update successful")); } else { ScheduleData.Save(scheduleEntity); return(new HttpStatusCodeResult(201, "Creation successful")); } }
public int AddSchedule(DocumentBO docBo, ScheduleBO schBO) { string connection = ConfigurationManager.ConnectionStrings["TSConnect"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); SqlCommand cmd = new SqlCommand("TS_AddSchedule", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@batchId", schBO.BatchId); cmd.Parameters.AddWithValue("@userId", docBo.UploadedBy); cmd.Parameters.AddWithValue("@DateFrom", schBO.StartFrom); cmd.Parameters.AddWithValue("@dateTo", schBO.EndOn); cmd.Parameters.AddWithValue("@timeSlot", schBO.TimeSlot); cmd.Parameters.AddWithValue("@Subject", schBO.Subject); cmd.Parameters.AddWithValue("@notes", docBo.File); cmd.Parameters.AddWithValue("@uploadedOn", docBo.UploadedOn); cmd.Parameters.AddWithValue("@desc", docBo.Description); int result = cmd.ExecuteNonQuery(); return(result); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { if (uploadNotes.HasFile) { string strExtension = System.IO.Path.GetExtension(uploadNotes.FileName); if (strExtension == ".docx" || strExtension == ".doc" || strExtension == ".pdf" || strExtension == ".xlsx" || strExtension == ".xlsm") { AdminBAL _resourcesBAL = new AdminBAL(); string strname = uploadNotes.FileName.ToString(); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss"); uploadNotes.SaveAs(Server.MapPath("~/Images/Uploaded Documents") + fileName + strname); string filename = System.IO.Path.GetFileName(uploadNotes.FileName); if (DateTime.Parse(txtBoxFrom.Text) >= DateTime.Now && DateTime.Parse(txtBoxTo.Text) >= DateTime.Now) { if (DateTime.Parse(txtBoxFrom.Text) <= DateTime.Parse(txtBoxTo.Text)) { ScheduleBO schedule = new ScheduleBO { StartFrom = DateTime.Parse(txtBoxFrom.Text), EndOn = DateTime.Parse(txtBoxTo.Text), BatchId = txtBoxId.Text, Subject = txtBoxSubject.Text, TimeSlot = dropDownTime.SelectedValue }; DocumentBO notes = new DocumentBO { Subject = txtBoxSubject.Text, UploadedBy = Session["UserId"].ToString(), UploadedOn = DateTime.Now, File = "~/Images/Uploaded Documents" + fileName + strname, Description = txtBoxDesc.Text }; UserBAL scheduleList = new UserBAL(); int result = scheduleList.AddScheduleBAL(notes, schedule); if (result >= 1) { lblStatus.Text = "Schedule Added Successfully!! Pls Refresh the Page"; hiddenSchedule.Value = ""; } else { lblStatus.Text = "BatchID already exists!!"; } } else { lblStatus.Text = "End date should be after start date !!"; } } else { lblStatus.Text = "Schedule for Past Dates are not allowed"; } } } else { lblStatus.Text = "Please Upload Notes"; } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
public int AddScheduleBAL(DocumentBO docBO, ScheduleBO schBO) { return(_document.AddSchedule(docBO, schBO)); }