public MemberModel CreateProjectMember(MemberModel memberModel) { // Mapp to backend model var member = new ProjectMember(); if (memberModel != null) { member = ApplicationMapper.MapProjectMember(memberModel); } // Create P.Member bool memberExists; bool userExists; ProjectMemberView pmv = projectRepository.CreateProjectMember(member, out memberExists, out userExists); //If the member is a new member if (!userExists) { if (!string.IsNullOrEmpty(pmv.UserEmail)) { ITextReplace replace = new TextReplace(); //replace.Add("%name%", pmv.UserName); replace.Add("%username%", pmv.UserEmail.Trim()); string body = replace.ReplaceFromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates", "NewUser.html")); // TODO replace with setting MailService smtp = new MailService("http://communicationservice.woxion.com/MailService.asmx"); bool result = smtp.Send("Projektplaneraren", "*****@*****.**", pmv.UserEmail.Trim(), null, "Projektplaneraren", body); } else { throw new Exception("Could not send new member email. Email is null or empty."); } } MemberModel createMemberModel = ApplicationMapper.MapProjectMemberView(pmv); createMemberModel.memberExists = memberExists; createMemberModel.MemberRoles = memberModel.MemberRoles; return(createMemberModel); }