public ActionResult Create([Bind(Include = "id,DateTimeFrom,DateTimeTo,EmpId")] OffDay offDays) { if (ModelState.IsValid) { db.OffDaysSchedule.Add(offDays); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(offDays)); }
public ActionResult Create([Bind(Include = "EmployeeID,Name,PhoneNumber,City,PostalCode,StreetAddress")] EmployeeContacts employeeContacts) { if (ModelState.IsValid) { db.EmployeeContacts.Add(employeeContacts); db.SaveChanges(); return(RedirectToAction("Index/" + employeeContacts.EmployeeID)); } return(View(employeeContacts)); }
public ActionResult Create([Bind(Include = "EmployeeID,Name,ContactName,ContactEmail,ContactPhone,ContactCity,ContactAddress")] EmergencyContact emergencyContact) { if (ModelState.IsValid) { db.EmergencyContact.Add(emergencyContact); db.SaveChanges(); return(RedirectToAction("Index/" + emergencyContact.EmployeeID)); } return(View(emergencyContact)); }
public ActionResult Create([Bind(Include = "ID,BranchName,Category,SubCategory,Description,MinutesPerUnit,CostPerUnit,Currency")] ServiceType serviceType) { if (ModelState.IsValid) { db.ServiceTypes.Add(serviceType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(serviceType)); }
public ActionResult Create([Bind(Include = "EmpId,ID,UserId,DateFrom,DateTo,TimeFrom,TimeTo")] Schedules scheduleModel, OffDay offday) { if (ModelState.IsValid) { db.ScheduleModels.Add(scheduleModel); db.OffDaysSchedule.Add(offday); db.SaveChanges(); return(RedirectToAction("Index/" + scheduleModel.EmpId)); } return(View(scheduleModel)); }
public ActionResult Create([Bind(Include = "ID,ContactID,Name,Phone,Address,BillingAddress")] Client client) { if (ModelState.IsValid) { client.ID = Guid.NewGuid(); db.Clients.Add(client); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(client)); }
public ActionResult Create([Bind(Include = "ID,ServiceTypeID,ClientID,StartDate,EndDate,RepeatOption,RepeatUntil,ShiftID")] Service service) { if (ModelState.IsValid) { service.ID = Guid.NewGuid(); db.Services.Add(service); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(service)); }
public void Add(MessageBoard model) { using (var db = new CRMDBContext()) { db.MessageBoards.Add(model); db.SaveChanges(); } }
public ActionResult Create([Bind(Include = "ID,ContactID,EmployeeID,QualificationsID,Name,Password,Position,StaffType,EmailAddress,BranchName,ContactInformation,EmergencyContact")] Employee employee, EmployeeContacts employeeContact, EmergencyContact emergencyContact, EmployeeQualifications qualify, Schedules schedule, string[] Qualifications, string ID, string Name) { if (ModelState.IsValid) { for (int i = 0; i < Qualifications.Length; i++) { string results = Qualifications[i]; qualify.Qualifications = results; qualify.EmployeeID = ID; db.EmployeeQualifications.Add(qualify); db.SaveChanges(); } employeeContact.EmployeeID = ID; emergencyContact.EmployeeID = ID; //schedule.EmpId = Convert.ToInt32(ID); db.SaveChanges(); db.Employees.Add(employee); db.EmployeeContacts.Add(employeeContact); db.EmergencyContact.Add(emergencyContact); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Create([Bind(Include = "Name,ParentBranch,Address")] Branches branch) { //if (file != null) //{ // string pic = System.IO.Path.GetFileName(file.FileName); // string path = System.IO.Path.Combine( // Server.MapPath("../Pictures"), pic); // // file is uploaded // file.SaveAs(path); // // save the image path path to the database or you can send image // // directly to database // using (MemoryStream ms = new MemoryStream()) // { // file.InputStream.CopyTo(ms); // byte[] array = ms.GetBuffer(); // } //} if (ModelState.IsValid) { try { db.Branches.Add(branch); db.SaveChanges(); } catch (Exception e) { //ViewBag.errorMessage = "Name Already Exits in database"; //CreateDropDownList(); return(View(branch)); } return(RedirectToAction("Index")); } return(View(branch)); }
public ContentResult Save(int?id, FormCollection actionValues, string text) { var action = new DataAction(actionValues); try { var changedEvent = (Shift)DHXEventsHelper.Bind(typeof(Shift), actionValues); var data = new CRMDBContext(); switch (action.Type) { case DataActionTypes.Insert: data.Shift.Add(changedEvent); action.TargetId = changedEvent.ID; //assign postoperational id changedEvent.Description = text; break; case DataActionTypes.Delete: changedEvent = data.Shift.SingleOrDefault(ev => ev.ID == action.SourceId); data.Shift.Remove(changedEvent); break; default: // "update" var eventToUpdate = data.Shift.SingleOrDefault(ev => ev.ID == action.SourceId); changedEvent.Description = text; DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>() { "id" }); break; } data.SaveChanges(); action.TargetId = changedEvent.ID; } catch //(Exception e) { action.Type = DataActionTypes.Error; // Log the exception. //ExceptionUtility.LogException(e, action.Type.ToString()); } return((ContentResult) new AjaxSaveResponse(action)); }
public ActionResult Create([Bind(Include = "Title,Description,StartDate,EndDate,Repeated,RepeatedOption,RepeatedEvery,RepeatedTimes,RepeatedEnd,RepeatedMonday,RepeatedTuesday,RepeatedWednesday,RepeatedThursday,RepeatedFriday,RepeatedSaturday,RepeatedSunday")] Events events, string services) { if (events.Repeated == true) { if (events.RepeatedOption == "Hourly") { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddHours(1); events.EndDate = events.EndDate.AddHours(1); } db.Events.Add(events); db.SaveChanges(); } return(RedirectToAction("Index")); } if (events.RepeatedOption == "Daily") { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } db.Events.Add(events); db.SaveChanges(); } return(RedirectToAction("Index")); } else if (events.RepeatedOption == "Weekly") { if (events.RepeatedMonday == true) { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); while (events.StartDate.DayOfWeek != DayOfWeek.Monday) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } } db.Events.Add(events); db.SaveChanges(); } } if (events.RepeatedTuesday == true) { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); while (events.StartDate.DayOfWeek != DayOfWeek.Tuesday) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } } db.Events.Add(events); db.SaveChanges(); } } if (events.RepeatedWednesday == true) { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); while (events.StartDate.DayOfWeek != DayOfWeek.Wednesday) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } } db.Events.Add(events); db.SaveChanges(); } } if (events.RepeatedThursday == true) { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); while (events.StartDate.DayOfWeek != DayOfWeek.Thursday) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } } db.Events.Add(events); db.SaveChanges(); } } if (events.RepeatedFriday == true) { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); while (events.StartDate.DayOfWeek != DayOfWeek.Friday) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } } db.Events.Add(events); db.SaveChanges(); } } if (events.RepeatedSaturday == true) { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); while (events.StartDate.DayOfWeek != DayOfWeek.Saturday) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } } db.Events.Add(events); db.SaveChanges(); } } if (events.RepeatedSunday == true) { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); while (events.StartDate.DayOfWeek != DayOfWeek.Sunday) { events.StartDate = events.StartDate.AddDays(1); events.EndDate = events.EndDate.AddDays(1); } } db.Events.Add(events); db.SaveChanges(); } } return(RedirectToAction("Index")); } else if (events.RepeatedOption == "Monthly") { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddMonths(1); events.EndDate = events.EndDate.AddMonths(1); } db.Events.Add(events); db.SaveChanges(); } return(RedirectToAction("Index")); } else if (events.RepeatedOption == "Yearly") { //db.Events.Add(events); //db.SaveChanges(); for (int i = 0; i < (events.RepeatedTimes); i++) { for (int j = 0; j < events.RepeatedEvery; j++) { events.StartDate = events.StartDate.AddYears(1); events.EndDate = events.EndDate.AddYears(1); } db.Events.Add(events); db.SaveChanges(); } return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); }
public bool SendSmsResponse(string phone, string verCode) { String product = "Dysmsapi"; //短信API产品名称(短信产品名固定,无需修改) String domain = "dysmsapi.aliyuncs.com"; //短信API产品域名(接口地址固定,无需修改) String accessKeyId = ""; //你的accessKeyId,参考本文档步骤2 String accessKeySecret = ""; //你的accessKeySecret,参考本文档步骤2 IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret); //IAcsClient client = new DefaultAcsClient(profile); // SingleSendSmsRequest request = new SingleSendSmsRequest(); //初始化ascClient,暂时不支持多region(请勿修改) DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); IAcsClient acsClient = new DefaultAcsClient(profile); SendSmsRequest request = new SendSmsRequest(); SendSmsResponse sendSmsResponse = new SendSmsResponse(); try { //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式,发送国际/港澳台消息时,接收号码格式为00+国际区号+号码,如“0085200000000” request.PhoneNumbers = phone; //必填:短信签名-可在短信控制台中找到 request.SignName = "广东烧腊"; //必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版 request.TemplateCode = "SMS_00000001"; //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 request.TemplateParam = string.Format("\"code\":\"{0}\"}", verCode); //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者 request.OutId = "yourOutId"; //请求失败这里会抛ClientException异常 sendSmsResponse = acsClient.GetAcsResponse(request); } catch (ServerException ex) { Log.Error("短信发送调用阿里云Api出现未处理异常", ex.ToString()); } catch (ClientException ex) { Log.Error("短信发送调用阿里云Api出现未处理异常", ex.ToString()); } finally { var sendSmsLog = new SendSmsLog(); sendSmsLog.Phone = phone; sendSmsLog.VerCode = verCode; sendSmsLog.IsSuccess = false; if (sendSmsResponse != null) { sendSmsLog.RequestId = sendSmsResponse.RequestId; sendSmsLog.BizId = sendSmsResponse.BizId; sendSmsLog.Code = sendSmsResponse.Code; sendSmsLog.Message = sendSmsResponse.Message; sendSmsLog.IsSuccess = sendSmsResponse.Code == "OK"; } sendSmsLog.Createtime = DateTime.Now; using (var db = new CRMDBContext()) { db.SendSmsLogs.Add(sendSmsLog); db.SaveChanges(); } } return(false); }